回答編集履歴

1

追記

2020/05/16 01:20

投稿

winterboum
winterboum

スコア23329

test CHANGED
@@ -31,3 +31,21 @@
31
31
  Tagは一つしかつけられないのか、複数つけられるのかによって回答が変わります。
32
32
 
33
33
  どちらでしょう?
34
+
35
+
36
+
37
+ ###ひとつだけなのでしたら
38
+
39
+ 0. Postのtagは tag_id(integer)に替える
40
+
41
+ 0. class Post のvalidates,has_many 3行は削除し`belongs_to :tag`にする
42
+
43
+ ただし、tag無しでも良しとするなら`belongs_to :tag, optional: true`
44
+
45
+ 0. ` form.collection_select :tags_ids,` は ` form.collection_select :tags_id,`
46
+
47
+ 0. `permit(:tag, :title, :text, :image)` は `permit(:tag_id, :title, :text, :image)`
48
+
49
+
50
+
51
+ で行けるかな