PaperTrailActor
This gem is an extension to paper_trail gem https://github.com/airblade/paper_trail. That means you need to pre install paper_trail gem. This gem will add one more method actor to instances of PaperTrail::Version that will return you the ActiveRecord object who was responsible for change.
Supported Rails
This Gem only support >= rails 4.1.0 and above versions.
Installation
- Add PaperTrailActor to your
Gemfile.
gem 'paper_trail_actor'
- And then execute:
bundle install
Basic Usage
Basically this gem works on stroring global_id to whodunnit field of PaperTrail::Version table. As this is an additional extension installed, this will not hinder / break existing paper_trail functionalities.
= Widget.find 42
.versions # [<PaperTrail::Version>, <PaperTrail::Version>, ...]
v = .versions.last
Now you can also store object to PaperTrail.whodunnit=, and if object will be instance of ActiveRecord::Base it will store the global id in the version's whodunnit column.
And you can also retrieve the actually object later just by using method actor.
actor = actor_paper_trail
PaperTrail.whodunnit = actor
PaperTrail.actor
.update_attributes :name => 'Wibble'
.versions.last.actor
Contributing
- Fork it ( https://github.com/[my-github-username]/paper_trail_actor/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request