Self-referential many-many joins with :through


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: that fixed them only went
through 5 days ago…


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


class Grouping < ActiveRecord::Base

belongs_to :item,
:class_name => “Topic”,
:foreign_key => “item_id”

belongs_to :group,
:class_name => “Topic”,
:foreign_key => “group_id”