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 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts