Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/models/chrno_audit/audit_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def after_destroy( entity )
# @param [ActiveRecord::Base] entity
# @param [#to_s] action
#
def create_audit_record!( entity, action )
def create_audit_record!( entity, action, params = {} )
# Ничего не делаем, если аудит данного действия отключён
return unless entity.class.auditable_actions.include? action

Expand All @@ -51,13 +51,16 @@ def create_audit_record!( entity, action )
# Ничего не делаем если модель не изменилась
return if entity.class.auditable_options[ :ignore_empty_diff ] && changes_to_store.empty? && action != :destroy

ChrnoAudit::AuditRecord.create do |record|
audit_record = ChrnoAudit::AuditRecord.new do |record|
record.action = action.to_s
record.auditable = entity
record.diff = changes_to_store
record.initiator = context.delete( :initiator ) || context.delete( :current_user )
record.context = context
end

audit_record.save! unless params[:nosave]
audit_record
end

##
Expand Down