Forum: Ruby on Rails How to describe self join in a model

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.
Ali (Guest)
on 2008-12-07 12:38
(Received via mailing list)
Hi ,
     I am new to rails, and i need to know one thing, i have a table
called Categories and i want to self join it in such a way , that one
category could be a parent of many categories, but could be child of
only one category.

Please tell me how to tell rails , in my Category Model, does the
following work for me ?

class Category

 belongs_to :category
 has_many :categories

end
Ed (Guest)
on 2008-12-07 17:51
(Received via mailing list)
This topic is locked and can not be replied to.