I found the solution to my problem. The situation is that class A has a habtm relationship to class B and also has a has_many and belongs_to relationship to itself. This results in two columns named a_id in the DB, one in the join table and one in A's table. When fetching the set of As via B, Rails apparently uses the a_id from the join table to construct instances of A. This causes A's belongs_to relationship to point to itself instead of its real A owner. To fix this, I changed A's habtm to "has_and_belongs_to_many :bs, :foreign_key => 'a_ref'" and B's habtm to "has_and_belongs_to_many :as, :association_foreign_key => 'a_ref'", with the join table using a_ref instead of a_id.
-Russ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

