在控制器中,我试图访问一个深度嵌套的参数。这是我的参数跟踪。
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"2j+Nh5C7jPkNOsQnWoA0wtG/vWxLMpyKt6aiC2UmxgY=",
"inventory"=>{"ingredients_attributes"=>{"0"=>{"ingredient_name"=>"Bread"}},
"purchase_date"=>"11",
"purchase_price"=>"11",
"quantity_bought"=>"11"},
"commit"=>"Create Inventory"}
我正在尝试从中检索“面包”。我尝试了params[:inventory][:ingredient][:ingredient_name]
其他变体。什么是正确的语法?
如果重要的话,
Inventory has_many :ingredients
Inventory accepts_nested_attributes_for :inventories
谢谢!