Jeremy Walker

Software Developer & Social Entrepreneur

Rails' update_attribute is deprecated from 3.2.7

The difference between update_attribute and update_attributes has confused new Rails developers for a long time. The key difference was that update_attribute did not run validations, where as update_attributes did.

As of Rails 3.2.7, update_attribute no longer exists in master and is deprecated in Rails 3. Xavier Noria provided a bit of history on this in a Rails Core group thread on the issue, which I found interesting.

So, to summarise:

  • If you use update_attribute provided, change to update_column.
  • If you use update_attributes, you can carry on as normal.

Share This Post



Robert Reiz

Good to know. I am using "update_attributes" in VersionEye. What is the equivalent for that? "update_columns"? Or should I use "update_column" multiple times for each column? That would be not so cool.


Jeremy Walker

Robert - update_attributes will stay as it is. It's only update_attribute that's been removed :)


Grammar Nazi

Deprecated. Deprecated. Deprecated.



Not sure yet why update_attribute is deprecated. update_column does not perform callbacks including updating the timestamp as update_attribute does. Does anyone have a recommendation for a one-liner, fast executing code to accomplish the same functionality?




So, one replaces one confusing method with another one? ActiveRecord should abstract the connection between physical and logical representation, in my eyes. Therefore, the notion or exposal of column confuses me in an ActiveRecord model. Not to mention, both functions behave differently. update_attribute could be called on a new record, update_column can't.

Not defending update_attribute here, just suggesting the solution might not have been the perfect one, at least in my opinion.

Post a Comment

I'd love to hear your thoughts :)