whitelisting deeply nested strong parameters in rails

一曲冷凌霜 提交于 2019-12-04 21:14:16

I ended up building another model to store the conditions and using accepts_nested_attributes_for to create the conditions all within the course_listing controller.

I had to add

conditions_attributes: [:id, :attr, :pred, :val, :_destroy]

to my permit call in order to make everything work. The middle three are my own attributes, the :id prevents Rails from adding new conditions with every edit, and the :_destroy is so you can delete conditions.

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