我正在构建一个API端点来更新模型。除了嵌套的资源,我可以更新每个列,我已经尝试了不同的技术途径,但似乎没有任何工作通过API/Json更新嵌套资源
这是我试图发送到服务器的JSON
{
"reservation": {
"reservation_dates": [
{
"is_desirable": true,
"date": "5-10-2019"
}
]
}
}
我得到一个unpermitted_param从reservation_date虽然我已经把它添加到我的
def permitted_attributes_for_update
params.require(:reservation).permit(:date, :time, :comment, :budget, :currency, :status,
:general_text, :idea_text, :artist_text, :desired_city,
:desired_country, :desired_googleid, :studio_id, :artist_id,
:tattoos, reservation_dates: [], general_url_array: [],idea_url_array: [],
artist_url_array: [])
end
我想要么能够直接从JSON更新,或者至少允许阵列,所以我可以在我的UpdateService
以后使用感谢您的帮助
edit: this is the error I'm getting
用确切的错误更新问题。 – Pavan
你允许在模型中嵌套属性吗? – 8bithero
我有@ 8bithero –