0

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?

Joe Arasin
  • 103
  • 1
  • 9

1 Answers1

2

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
  • 9,719
  • 2
  • 37
  • 41