Module: RailsAuditLog::Auditable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/concerns/rails_audit_log/auditable.rb
Overview
Include in any ActiveRecord model to automatically track create, update, and destroy events as AuditLogEntry records.
Basic usage
class Article < ApplicationRecord
include RailsAuditLog::Auditable
end
Configuring tracking
class Article < ApplicationRecord
include RailsAuditLog::Auditable
audit_log only: %i[title body],
meta: { tenant_id: -> { Current.tenant_id } },
version_limit: 50,
async: true
end
Adds a polymorphic has_many :audit_log_entries association to the model.
Instance Method Summary collapse
-
#skip_audit_log { ... } ⇒ Object
Executes the block with audit logging disabled for this record’s writes.
Instance Method Details
#skip_audit_log { ... } ⇒ Object
Executes the block with audit logging disabled for this record’s writes. A convenience wrapper around RailsAuditLog.disable.
142 143 144 |
# File 'app/concerns/rails_audit_log/auditable.rb', line 142 def skip_audit_log RailsAuditLog.disable { yield } end |