feat: add auditlogs for account model (#7511)

This commit is contained in:
Vishnu Narayanan
2023-07-19 23:52:34 +05:30
committed by GitHub
parent 1d718b92b7
commit ea825d49da
6 changed files with 21 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ module Enterprise::Audit::Account
extend ActiveSupport::Concern
included do
audited except: :updated_at, on: [:update]
has_associated_audits
end
end

View File

@@ -5,7 +5,11 @@ class Enterprise::AuditLog < Audited::Audit
def log_additional_information
# rubocop:disable Rails/SkipsModelValidations
update_columns(username: user&.email)
if auditable_type == 'Account' && auditable_id.present?
update_columns(associated_type: auditable_type, associated_id: auditable_id, username: user&.email)
else
update_columns(username: user&.email)
end
# rubocop:enable Rails/SkipsModelValidations
end
end