preventing delete of parent with children.

I’m lookin for an equilvalent to SQL ‘… on delete restrict’. To prevent deleting a parent record if there are related children records. Looking at the :dependent => options I see

:dependent => :destroy and :dependent => :nullify,

but not a :dependent => :restrict?

What is the best solution in this case?

Use a before_destroy callback on the parent?

http://rdoc.caboo.se/doc/classes/ActiveRecord/Callbacks.html#M005369

http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M000920

-Rob

Rob Biedenharn http://agileconsultingllc.com

Rob@AgileConsultingLLC.com