add LogDestroyPerformer concern to be included in models where we want log destroy action

This commit is contained in:
Mohamed ABDELLANI
2024-05-09 14:38:21 +01:00
parent 4a3f4136df
commit 40b2361572

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'active_support/concern'
module LogDestroyPerformer
extend ActiveSupport::Concern
included do
attr_accessor :destroyed_by
after_destroy :log_who_destroyed
def log_who_destroyed
return if destroyed_by.nil?
Rails.logger.info "#{self.class} #{id} deleted by #{destroyed_by.id}"
end
end
end