Skip to content

Instantly share code, notes, and snippets.

@monzou
Last active December 24, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monzou/6839974 to your computer and use it in GitHub Desktop.
Save monzou/6839974 to your computer and use it in GitHub Desktop.
Make audits when destroy
ActiveSupport.on_load(:active_record) do
module ActiveRecord
class Base
class << self
def audit_with_destroy(*args)
audit_without_destroy(*args)
after_destroy { |record| record.snap!(:action => "destroy") }
end
alias_method_chain :audit, :destroy
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment