collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.34k stars 645 forks source link

How to ignore impersonated user ? #706

Open leoplct opened 2 months ago

leoplct commented 2 months ago

I want to exclude the impersonated user from tracking audits. I know that I can use this, but it's worsened performance due to JOIN.

class CustomModel < ActiveRecord::Base
  audited unless: Proc.new { |m| m.profile.user.admin? }
end

I'd rather prefer to set it in the initializer. Would be possible?

config/initializers/audited.rb

Audited.max_audits = 1000
Audited.current_user_method = :true_user