我有以下课程:
- 项目
- 人
- 人员>开发人员
- 人>经理
在Project模型中,我添加了以下语句:
has_and_belongs_to_many :people
accepts_nested_attributes_for :people
当然还有课堂上的适当陈述Person。如何通过该方法将 a 添加Developer到 a ?以下不起作用:Projectnested_attributes
@p.people_attributes = [{:name => "Epic Beard Man", :type => "Developer"}]
@p.people
=> [#<Person id: nil, name: "Epic Beard Man", type: nil>]
如您所见,type属性设置为nil而不是"Developer".