Override a Model's destroy Method Without Losing Callbacks
I needed to do this in Rails 2, and had trouble finding any anything about how it could be done. I did eventually find some information, so I thought I’d share.
Here’s how it looked for me:
class User < ActiveRecord::Base
has_many :attributes
def before_destroy
...
end
def destroy_without_callbacks
unless new_record?
update_attribute(:deleted_at, Time.now)
end
end
end
Also came across an article talking about some of the downsides to soft delete. Definitely a good reminder.