watch this  

the official mrchucho blog

The correct way to override ActiveRecord::Base#destroy

Posted 2008 Sep 30

In 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

Simply implementing #destroy will short-circuit the callback chain and skip the destroy method on any associations marked :dependent => :destroy.

Responses to "The correct way to override ActiveRecord::Base#destroy"

No responses yet.

Comments are now closed.
atom rss