Results 1 to 2 of 2
Thread: Issue with associations
Aug 5, 2008, 12:58 #1
- Join Date
- Dec 2002
- Denver, CO
- 0 Post(s)
- 0 Thread(s)
Issue with associations
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".
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.