【RoR】Ruby on Rails Part15
■ このスレッドは過去ログ倉庫に格納されています
0406nobodyさん
2012/09/25(火) 14:15:41.16ID:???A has_many Bs
A has_many Cs through Bs
C has_many Bs
C has_many As through Bs
B belongs to A
B belongs to C
で、ABCをまとめて更新したいです。
Aにaccepts_nested_attributes_for :Bs
Bにaccepts_nested_attributes_for :C
を設定して
Aのコントローラのdef newに
@a = A.new
@a.Bs.build.build_C
と書いていますが、そもそもこれが正しいのかに加え、def createの書き方もわかりません。
@a = A.new
@a.Bs.build.build_C(params[:A])
と書いてみましたが、params[:A]がCの要素として認識されてしまっている感じで
うまくいきません。
どなたかご教授ください……。
■ このスレッドは過去ログ倉庫に格納されています