On Jan 26, 2007, at 9:24 AM, Larry Kelly wrote:
> 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?
>
> --
> Best Regards,
> -Larry
> "Work, work, work...there is no satisfactory alternative."
> --- E.Taft Benson
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-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---