search for: nested_set_categories

Displaying 1 result from an estimated 1 matches for "nested_set_categories".

2005 Aug 05
0
Finding by inclusion in nested set
Say I have tasks with a belongs_to association to categories where the later act as a nested set. Now I want to find all tasks belonging to a specific category (given as primary key) or any of its sub-categories. SELECT tasks.*, tasks_category.name FROM categories AS nested_set_categories, tasks LEFT OUTER JOIN categories AS tasks_category ON tasks_category.id = tasks.category_id WHERE (parent.id = ?) AND (tasks_category.lft BETWEEN nested_set_categories.lft AND nested_set_categories.rgt) (The aliases in this snippets require a patch for ActiveRecord; see <http://dev....