mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add Paranoia#delete (original)
This commit is contained in:
15
config/initializers/paranoia.rb
Normal file
15
config/initializers/paranoia.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Paranoia
|
||||
def paranoia_delete
|
||||
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
||||
if persisted?
|
||||
# if a transaction exists, add the record so that after_commit
|
||||
# callbacks can be run
|
||||
add_to_transaction
|
||||
update_columns(paranoia_destroy_attributes)
|
||||
elsif !frozen?
|
||||
assign_attributes(paranoia_destroy_attributes)
|
||||
end
|
||||
self
|
||||
end
|
||||
alias_method :delete, :paranoia_delete
|
||||
end
|
||||
Reference in New Issue
Block a user