我有三个模特:Almon,Bela和Lingo
class Almon < ActiveRecord::Base
belongs_to :bela, dependent: :destroy
has_many :lingos, through: :bela, dependent: :delete_all
accepts_nested_attributes_for :bela
accepts_nested_attributes_for :lingos, :allow_destroy => true
end
我正在尝试在Almon中提交嵌套表单,我正在
无法修改关联&#Al;#Lingos&#39;因为源反思课&#39; Lingo&#39;与Bela&#39;相关联。 via:has_many。
有谁能告诉我我做错了什么?
答案 0 :(得分:0)
您需要使用has_many而不是belongs_to,如下所示:
has_many :belaes, dependent: :destroy
has_many :lingoes, through: :belaes, dependent: :delete_all