ruby-on-railsrubyrubygemsruby-on-rails-6paper-trail-gem

Papertrail: Do not log change if whodunnit blank?


I'm trying to use papertrail to audit changes made by specific users. Was just wondering if there is a way(globally if possible) to ignore logging changes made to records when there is no whodunnit value set?

I've looked at using has_paper_trail if : proc.{...} but I'm unsure on how to access version record info from here correctly.


Solution

  • PaperTrail uses PaperTrail.request.whodunnit in a global scope to define the whodunnit for your request. You could in this instance check the value of this in the if guard.

    My guess is all of the blank whodunnit are system generated in which case you might also just populate the whodunnit with a system user of sorts and then filter those out.