TrackHistory: An easy way to track changes

Hey guys,

I made a gem for tracking changes on specific fields in ActiveRecord models. Its very easy to get started using, and automatically creates models and associations to history objects which contain the changes made.

If you have a table like: users: (id, email, created_at)

And you'd like to track all of the changes the email has been through over time, in your model you'd just write:

class User < ActiveRecord::Base   track_history end

and create a table in a migration like: user_histories: (id, user_id, email_before, email_after, created_at)

Automatically when you start up your server, user instances will have #histories (an array of UserHistory objects) and UserHistory will have some convenience methods which you can read more about in the README.

You can also add annotations like:

class User < ActiveRecord::Base   track_history do     annotate(:day_of_week) { Time.zone.now.wday }   end end

And the value of the annotation will be saved whenever the object is updated.

There's are a bunch of other options to check out and configure, such as the ability to track creates and deletes cleanly.

Check it out! https://github.com/seejohnrun/track_history

John Crepezzi @seejohnrun

This looks very promising! Is there any magic in it to roll back to a previous state? Or is that out of scope for what it's meant to do?

Walter

acts_as_audited or acts_as_versioned, things like that.

Not yet, but I think its definitely in the scope and should be coming soon