Jordan Schwartz Jordan Schwartz - 6 months ago 14
Ruby Question

Update attribute without altering the updated_at field

I'm running rails 3.0. I have a object I want to change a boolean field on but do not want to change the updated_at timestamp. We won't be upgrading rails any time soon, so update_column is out of the question. I'd rather not make model-level changes to support this (like in this post: http://blog.bigbinary.com/2009/01/21/override-automatic-timestamp-in-activerecord-rails.html), since many of objects of this type may have methods called on them at the same time.

Answer

You could use .update_all:

User.where(:id => @user.id).update_all(:your_bool_field => true)