Rails routing for nested controller's catch-all
In rails 3, how do I make all controllers/actions including nested controllers work without specifying them in routes.rb?
I开发者_如何学编程 uncommented the following line, but it doesn't work with nested controller.
match ':controller(/:action(/:id(.:format)))'
I want to make /preview/draft1/index work.
Thanks.
Sam
You need to make a route with a contraint on the controller:
match ':controller(/:action(/:id(.:format)))', :controller => /preview\/[^\/]+/
Where "preview" is the name of the namespace.
And then:
match ':controller(/:action(/:id(.:format)))'
For more info: http://edgeguides.rubyonrails.org/routing.html#dynamic-segments
精彩评论