有以下JSON:
{"id":"6","restaurant_menus":[{"restaurant_menu_items":[{"image":null,"title":"1","description":"2","cost":"3"}],"title":"Title"}],"format":"json","action":"update","controller":"restaurants","restaurant":{"id":6}}
我希望Rails通过嵌套的restaurant_menu_items传递id,restaurant_menus,我试着用它来做:
params.require(:restaurant).permit(:id, { restaurant_menus: [:id, :title, { restaurant_menu_items: [:id, :image, :title, :description, :cost] } ] })
但是这段代码只传递了第一个'id'。我该怎么办?
答案 0 :(得分:0)
就像这样。
params.require(:restaurant).permit(:id,
restaurant_menus: [
:id,
:title,
restaurant_menu_items: [
:id,
:image,
:title,
:description,
:cost
]] )