志田・タンブラー・裕樹

Apr 2
“# こんなハッシュがparams[:cooking_recipe]に入ってくれば子を新たに作るのではなく更新する # {:name => “肉じゃが”, # :ingredients_attributes => # { # “13” => {:name => “じゃがいも”}, # “14” => {:name => “にんじん”} # } # } recipe = CookingRecipe.find(params[:id]) recipe.attributes = params[:cooking_recipe] recipe.save ….” Nested AttributesとNested Model Formsを使って親子オブジェクトを一括で登録/変更するには

Page 1 of 1