Self-referential many-many joins with :through


#1

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