Forum: Ruby on Rails Self-referential many-many joins with :through

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Henry T. (Guest)
on 2006-03-30 01:18
(Received via mailing list)
I thought I had this nailed but.. now I'm seeing spots..

I've included my models below, feel free to ignore them. I'm really
just after an example that works. I couldnt find one on the wiki...
which is fair enough considering Ricks patch:
http://dev.rubyonrails.org/changeset/4022 that fixed them only went
through 5 days ago..

Cheers
-henster

***********************************************************************************
class Topic < ActiveRecord::Base

  has_many  :item_collection, :class_name => "Grouping",  :foreign_key
=> "item_id"
  has_many  :group_collection, :class_name => "Grouping",
:foreign_key => "group_id"

  has_many  :groups, :through => :group_colletion
  has_many  :items, :through => :item_collection

end
**********************************************************************************

***********************************************************************************
class Grouping < ActiveRecord::Base

  belongs_to  :item,
              :class_name => "Topic",
              :foreign_key => "item_id"

  belongs_to  :group,
              :class_name => "Topic",
              :foreign_key => "group_id"
end
*********************************************************************************
This topic is locked and can not be replied to.