我有三个模特:艾蒙,贝拉和林戈
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中提交一个嵌套的表单,
无法修改关联'Almon#Lingos‘,因为源反射类'Lingo’通过:has_many与'Bela‘相关联。
有人能告诉我我做错了什么吗?
发布于 2014-08-19 13:06:11
您需要使用has_many而不是belongs_to,如下所示:
has_many :belaes, dependent: :destroy
has_many :lingoes, through: :belaes, dependent: :delete_allhttps://stackoverflow.com/questions/25383421
复制相似问题