質問編集履歴

1

Many-to-Many(has_many_through) で project と user を更新できるようモデル内を書き換えました。

2021/05/20 07:37

投稿

engineer_maple
engineer_maple

スコア0

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  has_many :user_projects
18
18
 
19
- accepts_nested_attributes_for :user_projects
19
+ has_many :projects, through: :user_projects
20
20
 
21
21
  end
22
22
 
@@ -29,6 +29,8 @@
29
29
  class Project < ApplicationRecord
30
30
 
31
31
  has_many :user_projects
32
+
33
+ has_many :users, through: :user_projects
32
34
 
33
35
  end
34
36