例えば「モデルA」「モデルB」「モデルC」「モデルD」が存在し、一つのコントローラーでこれらのモデルにデータを保存していくことは可能ですか?
モデルの数だけコントローラーを作成しなければならないのでしょうか?
コントローラー
ruby
1 def index 2@a = A.last 3@b = B.last 4@c = C.last 5@d = D.last 6 end 7 8def new 9 @a = A.new 10 @b = B.new 11 @c = C.new 12 @d = D.new 13end 14 15 def create 16 @a = A.new(schedule_params) 17 @b = B.new(schedule_params) 18 @c = C.new(schedule_params) 19 @d = D.new(schedule_params) 20 end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。