How to describe self join in a model


#1

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


#2

:acts_as_tree: http://wiki.rubyonrails.org/rails/pages/ActsAsTree