Get Whodunnit User Instance From PaperTrail

Posted By Weston Ganger

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:

Article Topic:Software Development - Rails

Date:June 21, 2015