On Thu, Jan 15, 2009 at 8:51 AM, Greg Hauptmann <
[email protected]> wrote:

> just wondering what I would put in:
> (a) before_destroy - then proactively destroy the other associated object,
> BUT if those objects had a before_destory this could become circular no?
> (b) after_destroy - test to see if both ends were destroy, but if one end
> tests first prior to the other end being destroyed this would be an issue
> no?
>
>
>>> Greg, put in a before_delete callback to see if the deletion would leave
>>> the one side open and then return false if it would.
>>>
>>>
>> Sorry, it's before_destroy
>
>
I wouldn't try do a dependant destroy, I'd return false (to stop the
destroy) or raise an error so that the destroy never happens.
If you want to destroy with the dependant you are going to have to put a
special case destroy on one side that will automatically destroy it's
association.

So the one will make sure it can't be destroyed if it will break referential
integrity, the other side will destroy it's dependent along with itself.

-- 
Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to