Rails 3 vs Rails 2“狂野控制器”路由
我试图让我的 Rails 3 项目自动解析命名空间控制器,类似于 Rails 2 的行为。例如(Rails 2):
$ rails pathtest && cd pathtest
$ script/generate controller First
$ script/generate controller first/second
$ script/generate controller first/second/third
$ script/server
请求:
但是,Rails 3 使用“野生控制器”路径产生不同的路由。
$rails 新路径测试 &&光盘路径测试
$rails 首先生成控制器
$ Rails 首先/第二生成控制器
$rails 生成控制器第一/第二/第三
## 配置/routes.rb
Pathtest::Application.routes.draw 做
匹配 ':controller(/:action(/:id(.:format)))'
结尾
$ 导轨服务器
请求:
我开始认为命名空间控制器的自动解析不再是这样了?有没有人找到一种方法来自动解析这样的命名空间控制器?
谢谢!
I'm trying to get my Rails 3 project to automatically resolve namespaced controllers, similar to the Rails 2 behaviour. For example (Rails 2):
$ rails pathtest && cd pathtest
$ script/generate controller First
$ script/generate controller first/second
$ script/generate controller first/second/third
$ script/server
Requests to:
But, Rails 3 yields different routing using the 'wild controllers' path.
$ rails new pathtest && cd pathtest
$ rails generate controller First
$ rails generate controller first/second
$ rails generate controller first/second/third
## config/routes.rb
Pathtest::Application.routes.draw do
match ':controller(/:action(/:id(.:format)))'
end
$ rails server
Requests to:
I'm starting to think that kind of automatic resolution of namespaced controllers isn't the way anymore? Has anyone found a way to automatically resolve namespaced controllers like this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: