I have a categories table that has parent categories and sub categories that are attached via "parent_id"
I then have items that are attached to the specific category via "category_id".
My associations:
Item belongs_to Category
Category has_many Items
The item really always has a category_id that matches one of the sub categories but there are places where I need to get parent category as well.
So my question is how can I get the parent category?
Right now if I want the sub category I just do item.category.title (which works because of my association)...but I want to be able to do something like item.category.parent_id.title so I can get the title of the main parent category.
Any ideas?





Bookmarks