views:

570

answers:

1

I have a data structure that is basically a tree using :wesome nested set:

class category
  acts_as_nested_set

What I want to achieve are routes like

/categories/1/children/
/categories/1/children/new

I know I could fake it by making a separate controller, but it seems a bit non-DRY. Are there any better ways to do this?

+2  A: 

Have you tried this:

map.resources :categories do |categories|
  categories.resources :children, :controller => :categories, 
                                  :only => [:index, :new, :create]
end

Then you'll have to check for params[:category_id] in CategoriesController#index, #new, and #create to see if it is the nested route.

mckeed