开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜