私は次のクラスを持っています:
- 計画
- 人
- 人>開発者
- 人>マネージャー
Project
モデルに次のステートメントを追加しました。
has_and_belongs_to_many :people
accepts_nested_attributes_for :people
そしてもちろん、クラス内の適切なステートメントPerson
。メソッドを介してをに追加するDeveloper
にはどうすればよいですか?以下は機能しません。Project
nested_attributes
@p.people_attributes = [{:name => "Epic Beard Man", :type => "Developer"}]
@p.people
=> [#<Person id: nil, name: "Epic Beard Man", type: nil>]
ご覧のとおり、type
属性はnil
の代わりにに設定されています"Developer"
。