Module: Audited::Auditor::ClassMethods

Defined in:
lib/audited/auditor.rb

Instance Method Summary collapse

Instance Method Details

#audited(options = {}) ⇒ Object

  • redacted - Changes to these fields will be logged, but the values will not. This is useful, for example, if you wish to audit when a password is changed, without saving the actual password in the log. To store values as something other than ‘[REDACTED]’, pass an argument to the redaction_value option.

    class User < ActiveRecord::Base
      audited redacted: :password, redaction_value: SecureRandom.uuid
    end
    
  • if - Only audit the model when the given function returns true

  • unless - Only audit the model when the given function returns false

    class User < ActiveRecord::Base
      audited :if => :active?
    
      def active?
        self.status == 'active'
      end
    end
    


61
62
63
# File 'lib/audited/auditor.rb', line 61

def audited(options = {})
  audited? ? update_audited_options(options) : set_audit(options)
end