Nested fields and strong parameters

后端 未结 1 1837
春和景丽
春和景丽 2021-01-06 00:58

I am having a complex issue in Rails 4, which I will try to describe below. I am using simple form and awesome_nested_fields gems.

I have a bunch of events

1条回答
  •  借酒劲吻你
    2021-01-06 01:38

    Now that I think about it, it might be related to strong parameters. For update to work you need to allow id attributes also. In your permit params add id for speakers and any other nested nested resources in use that will be updated.

    Please give this a try:

    def event_params
      params.require(:event).permit(:title, :description, :type_id, :price, :program,
                                  :start_date, :end_date, :image, category_ids: [],
                                  speakers_attributes: [ :id, :name ])
    end 
    

    0 讨论(0)
提交回复
热议问题