开发者

Rails routing for nested controller's catch-all

开发者 https://www.devze.com 2023-03-16 21:15 出处:网络
In rails 3, how do I make all controllers/actions including nested controllers work without specifying them in routes.rb?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消