The correct way to override ActiveRecord::Base#destroy
Posted 2008 Sep 30In order to correctly override #destroy in an ActiveRecord model, you actually need to implement #destroy_without_callbacks like so:
def destroy_without_callbacks
unless new_record?
# do your custom stuff here, then save
end
freeze
end
Simply implementing #destroy will short-circuit the callback chain and skip the destroy method on any associations marked :dependent => :destroy.