Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Keeps track of when a specific column in an ActiveRecord model changed.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 vendor
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 column_timestamps.gemspec
Octocat-spinner-32 ginger_scenarios.rb


ActiveRecord manages your updated_at columns for you, updating the timestamp when your records change. This gem provides similar, but more granular functionality: in addition to a table-wide updated_at column, you can have additional timestamp columns that track when specific columns change.



gem install column_timestamps


Load the gem using Rails' 2.1+ gem support. In environment.rb:

config.gem 'column_timestamps'

Usage is pretty simple:

  • Create a new datetime column using the naming convention <column>_updated_at.

  • Include ColumnTimestamps in your model.


# in a migration...
create_table :users, :force => true do |t|
  t.string    :email_address
  t.string    :name
  t.string    :state
  t.datetime  :state_updated_at

# Model...
class User < ActiveRecord::Base
  include ColumnTimestamps

Anytime the state attribute of a user record is changed, the state_updated_at timestamp will be updated to reflect that.

Version Compatibility

column_timestamps relies upon the dirty attributes functionality introduced to ActiveRecord in version 2.1. It works on any version since 2.1, including 3.0.0.beta4. It works on ruby 1.8.6], 1.8.7 and 1.9.1.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2009-2010 Myron Marston. See LICENSE for details.

Something went wrong with that request. Please try again.