has_many

Grégory Pardoen
2007-07-20T21:37:17Z

Hi,

I have a table collection and a table collectionorganisation. The
collectionorganisation table is used to define a hierarchy between
collections.
So, in the table collectionorganisation there is two foreign key :
parent_id and son_id.

In the collection model, I define the two following has_many with
dependent => destroy :

  has_many :collectionorganisation, :foreign_key => "parent_id",
:dependent => :destroy
  has_many :collectionorganisation, :foreign_key => "son_id",
:dependent
=> :destroy

Unfortunatly, only the last depedent(son_id) is took into account. So
when a delete a collection that is present in the field son_id of a
record of collectionorganisation, then this record (in
collectionorganisation) is correctly deleted. But, if the collection is
present in the field parent_id, then nothing is done.

Someone can help me ?

Thanks in advance.

--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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