質問編集履歴
2
個人情報の削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,13 +78,13 @@
|
|
78
78
|
|
79
79
|
def new
|
80
80
|
@post = Post.new
|
81
|
-
@tag = @post.tags.new
|
81
|
+
@tag = @post.tags.new
|
82
82
|
end
|
83
83
|
|
84
84
|
def create
|
85
85
|
@post = current_user.posts.new(post_params)
|
86
|
-
tag_list = params[:tags][:name].split(',')
|
86
|
+
tag_list = params[:tags][:name].split(',')
|
87
|
-
@post_tag = params[:tags][:name]
|
87
|
+
@post_tag = params[:tags][:name]
|
88
88
|
#binding.pry
|
89
89
|
if @post.save
|
90
90
|
@post.save_tag(tag_list)
|
@@ -109,9 +109,9 @@
|
|
109
109
|
|
110
110
|
def update
|
111
111
|
@post = current_user.posts.find(params[:id])
|
112
|
-
#@post_tag = @post.tags.pluck(:name).join(',')
|
112
|
+
#@post_tag = @post.tags.pluck(:name).join(',')
|
113
|
-
@post_tag = params[:tags][:name]
|
113
|
+
@post_tag = params[:tags][:name]
|
114
|
-
tag_list = params[:tags][:name].split(',')
|
114
|
+
tag_list = params[:tags][:name].split(',')
|
115
115
|
if @post.update(post_params)
|
116
116
|
@post.save_tag(tag_list)
|
117
117
|
redirect_to post_path(@post), success: 'ポストを更新しました'
|
@@ -141,7 +141,7 @@
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def post_params
|
144
|
-
params.require(:post).permit(:title, :body, tags_attributes: [:name, :_destroy, :id])
|
144
|
+
params.require(:post).permit(:title, :body, tags_attributes: [:name, :_destroy, :id])
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
1
参考にした情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -270,3 +270,5 @@
|
|
270
270
|
|
271
271
|
[Rails]ransackで関連するモデル(親や子)のカラムをまたいで検索する方法
|
272
272
|
https://qiita.com/sew_sou19/items/520d4348b2eaa7bf792c
|
273
|
+
|
274
|
+
https://github.com/activerecord-hackery/ransack/issues/1127
|