How To Get Whodunnit User Instance From PaperTrail

Posted by Weston Ganger on June 21, 2015

When I called whodunnit with papertrail on a version I usually want the user instance.

We are going to add a monkey patch in config/intializers

# config/initializers/paper_trail_monkey_patch.rb
module PaperTrail
  class Version
    def user
      User.find(whodunnit) if whodunnit

Now whenever you want the user of a version just call user.


Related External Links:

Posted in Rails and Tagged with paper_trail rails whodunnit 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts