Paper Trail
Create a new rails application and generate a scaffold. Paper trail gem is used to track about the events that occur.
Add PaperTrail to your Gemfile.
gem 'paper_trail', '~> 4.0.0'
Add a versions table to your database.
bundle exec rails generate paper_trail:install
bundle exec rake db:migrate
Add has_paper_trail to the models you want to track.
Add has_paper_trail to your model to record every create, update, and destroy.
class Model_name < ActiveRecord::Base
has_paper_trail
end
You can check the version of details that are created with the command
test = Model.find 1
test.versions ## [<PaperTrail::Version>, <PaperTrail::Version>, ...]
irb(main):019:0> test.event
=> "create"
irb(main):020:0> test.created_at
=> Wed, 13 Jan 2016 08:47:25 UTC +00:00
irb(main):021:0> test.whodunnit
=> nil
Cheers !!