Rails: update_column works, but not update_attributes

后端 未结 3 473
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 19:40

I have a simple model:

class Reply < ActiveRecord::Base
  attr_accessible :body
  belongs_to :post
end

In my controller, I have a simple

3条回答
  •  再見小時候
    2020-12-12 20:26

    I had this same issue, but with Rails 4. The issue happens when you have params[] in update_attribute. In Rails 4 with strong parameters

    @reply.update_attributes(params[reply_params])
    

    should be

    @reply.update_attributes(reply_params)
    

    I'm not to familiar with Rails 3 but this should be the issue:

    @reply.update_attributes(params[:reply])
    

    should be

    @reply.update_attributes(:reply)
    

提交回复
热议问题