0
我有三種模型。模型通過多重屬性嵌套屬性到
class Business < ActiveRecord::Base
has_one :employee
accepts_nested_attributes_for :employee
end
class Employee < ActiveRecord::Base
has_one :slave
belongs_to :business
accepts_nested_attributes_for :slave
end
class Slave < ActiveRecord::Base
belongs_to :employee
end
我有一些奴隸參數被髮送到我的控制器更新奴隸和商業記錄。從屬參數由一個密鑰business_attributes
組成,並帶有更新的業務屬性。不過,我不確定如何正確連接它。
我應該在從屬模型中添加accepts_nested_attributes_for
以接受business_attributes
?或者我需要在employee_attributes
散列碼中包含business_attributes
,並且僱員模型accepts_nested_attributes_for
爲business_attributes
?任何幫助,將不勝感激。