【发布时间】:2016-08-29 14:19:57
【问题描述】:
我有以下 JSON:
{
"name": "pizza",
"ingredients": [
{"name": "tomato", "amount": 3, "unit": "un"},
{"name": "chesse", "amount": 100, "unit": "gr"}
]
}
我使用 POST 将此 JSON 传递给我的控制器,然后我需要信任此参数,但我无法允许哈希数组 ingredients。
如何允许?
我试过params.permit(:ingredients).permit(:name, :amount, :unit).to_h,但它不起作用。
【问题讨论】:
标签: ruby-on-rails json