Rails 4.0 Strong Parameters nested attributes with a key that points to a hash

后端 未结 6 1460
生来不讨喜
生来不讨喜 2020-12-01 00:43

I was playing around with Rails 4.x beta and trying to get nested attributes working with carrierwave. Not sure if what I\'m doing is the right direction. After searching

6条回答
  •  自闭症患者
    2020-12-01 01:42

    try

    def screenshot_params
      params.require(:screenshot).permit(:title, :assets_attributes => [:filename, :id, :screenshot_id])
    end
    

    I had this issue about a month ago and some searching around dug up this solution. It was adding the :id or :screenshot_id that fixed the problem (or both, I can't remember). This works in my code though.

提交回复
热议问题