私は次のクラスを持っています:
- 計画
- 人
- 人>開発者
- 人>マネージャー
Projectモデルに次のステートメントを追加しました。
has_and_belongs_to_many :people
accepts_nested_attributes_for :people
そしてもちろん、クラス内の適切なステートメントPerson。メソッドを介してをに追加するDeveloperにはどうすればよいですか?以下は機能しません。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"。