mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
add LogDestroyPerformer concern to be included in models where we want log destroy action
This commit is contained in:
17
app/models/concerns/log_destroy_performer.rb
Normal file
17
app/models/concerns/log_destroy_performer.rb
Normal 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
|
||||
Reference in New Issue
Block a user