Rails 2.3.2中的“ Touch” updated_at列

I have a process which iterates through a bunch of ActiveRecord models, does some processing, and saves the models again. Often though, the processing doesn't result in an changes to the attributes and so the updated_at column never changes (even though save is called).


  1. Add a separate timestamp column to the model (i.e., 'processed_at') and manage this myself, although this seems a bit wasteful/redundant.
  2. Or somehow override the management of the updated_at attribute?

我听说Rails 3会提供一种“触摸”方法,而这正是我在寻找的方法。



Actually the touch method is already in Rails 2.3.x, so you can simply do:


To update the updated_at column. Alternatively, to update some other column with the current date and time use: