假设我有 3 个模型A B C
,其中
class A
has_many :Bs, through: :Cs
accepts_nested_attributes_for :Cs
end
class B
has_many :As, through: :Cs
end
class C
belongs_to :A
belongs_to :B
end
在我看来,我有一些嵌套形式
= form_for @A do |f|
...
= f.fields_for :Cs do |builder|
...
但我得到一个错误
ArgumentError (No association found for name `C'. Has it been defined yet?)
我做错了什么?