Nested form update action producing duplicate results

久未见 提交于 2019-12-02 07:18:36

update_only does not work for has_many relationships. You need to add the nested attribute :id field to your strong parameters:

def application_params
   params.require(:application).permit(:job_id, :user_id, 
     answers_attributes:[:id, :question_id, :content]).merge(user_id: current_user.id,
     job_id: params[:job_id])
end

Try adding update_only to your call to accepts_nested_attributes_for.

accepts_nested_attributes_for :nested_attribute, update_only: true
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!