I'm following this tutorial which is working splendidly for has_many :through relationships. I've got normal things like category_product working.
However, I am not able to conceptualize this situation (nor get it to work): I have a Category that has related Categories. Since every category can have N categories... first off, is this actually a many-to-many situation (I'm pretty positive that it is)? Secondly, what would this look like? My migration looks like this:
create_table :categories do |t|
t.string :name
t.timestamps
end
create_table :related_categories, :id => false do |t|
t.integer :category_a_id
t.integer :category_b_id
end
and my model's guts are
has_many :related_categories, :foreign_key=>"category_a_id"
has_many :categories, :through => :related_categories, :source=>:category_a
This is obviously not right, though it's getting there (i.e., it's 100% broken). How can I do this?
Edit: I forgot this, but only here on SO (meaning it's not the answer):
class RelatedCategory < ActiveRecord::Base
belongs_to :category_a, :class_name=>"Category"
belongs_to :category_b, :class_name=>"Category"
end