我想從params
哈希值中提取用POST表單提取的id
和quantity
密鑰的值。Ruby On Rails:如何從POST請求中提取嵌套參數
參數:
params
# => {...
"form"=>
{"name"=>"joe",
"date_sent"=>"09/28/2016",
"emp_num"=>"54552452",
"items_attributes"=>{"1474227471986"=>{"id"=>"3", "quantity"=>"5", "_destroy"=>"false"}, "1474227474062"=>{"id"=>"4", "quantity"=>"3", "_destroy"=>"false"}},
"comments"=>"af",
"accepted"=>"false"},
"commit"=>"Submit",
"m"=>"true"}
你有什麼碼?嵌套散列是Ruby的一個非常基本的功能。 –