Touch records without running callbacks

ActiveRecord comes with a method touch Show archive.org snapshot which sets the updated_at timestamp to the current time. Unfortunately it also runs callbacks (and hence validations) on the receiving record, so it is unsuitable if you call it very often.

Use the attached initializer to get a touch_gently method which updates updated_at, but does not run callbacks:

User.find(5).touch_gently

The initializer will also give you a method touch_all_gently which touches a scope of records in a single query (also without running callbacks):

User.active.touch_all_gently
Henning Koch