我正在構建一個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 –