If I have a nested categories, where each category might have many sub-categories, and each category belongs to one parent category, how would I write the Category model ?
I thought it will be something like this:
Category
belongs_to :category
has_many :categories
where I have parent_category_id in the category table, is this a good relationship ? or do I need a second table to present a many to many relationship ? I think I need some thing like belongs_to_and_has_many ?
Any guidance will be appreciated
has_and_belongs_to_manyand a second table are not needed or appropriate for mapping this kinda structure.