Tracking ActiveRecord Attributes Changes Persistently ( after saved )

The problem: I have a User model with attributes name, address and current_job.
I want to run a cronjob which sends emails to all users who changed their address or current_job since my last run.

The solution: TrackIt gem


bundle install

In the console:

rails generate track_it User address current_job


rake db:migrate

That’s it – when a user changes his address/current_job it will be persistently marked until you decide to clear it.

Let’s try it on rails console:

This is the first gem I have published so I’m sure there are lots of things I missed and a lot of improvements to make. I will be more than pleased to take comments/suggestions from you.

Hope you’ll find it useful!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s