Custom ActiveRecord timestamps April 27th, 2009

Some legacy databases have already defined their own created_at or updated_at fields. They can be easily filled in with ActiveRecord before_save filters, but after implementing this behaviour a few times the urge arose to write something reusable, so I created the custom_timestamps plugin.

With custom_timestamps you can easily define the columns you want to be updated on creation/change

class LegacyModel < ActiveRecord::Base
  set_create_column :creation_time
  set_update_column :change_time
end

The plugin can be found on github.

tags: , , , l

2 Responses to “Custom ActiveRecord timestamps”

  • over 2 years ago Mitchell Blankenship said

    Thanks found this just when I needed it

  • over 2 years ago Dave LaDelfa said

    Yes, this came in very handy today.

Sorry, comments are closed for this article.