AuditModel
Track changes to your models, for auditing or versioning.
Installation
Add audit_model to your application's Gemfile
#!ruby
gem 'audit_model'
And then execute
rails g audit_model:install
rake db:migrate
For each model you want to audit you should run this command:
rails g audit_model:audit MODEL field1 field2 ...
rake db:migrate
Where MODEL is your model what you want to do audit and (field1, field2) are the fields that you want to be audited. Add auditable to the models you want to track.
#!ruby
class User < ActiveRecord::Base
auditable
end
Usage
In the model you have #audits method that returns the audits.
#!ruby
User.audits
Audits are ActiveRecord models, knowing that you can make any query based on ActiveRecord. You can do something like this:
#!ruby
User.audits.last
This will return the last change in the model.
License
AuditModel is released under the MIT License.
Contributing
Bug reports and pull requests are welcome on BitBucket at https://bitbucket.org/alissonbruno/audit_model