Rails 如何重写这个旧的路线map.connect?
如何将这条旧路线从 Rails 1.2.6 重写为 Rails 3? :
# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
我不知道应该如何使用匹配路线等。
我已经使用过:
match ':controller/service.wsdl', :action => 'wsdl'
但我认为它工作不正确
How do I rewrite this old route Rails 1.2.6 to Rails 3? :
# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
I can´t see how I should use match route etc.
I have used:
match ':controller/service.wsdl', :action => 'wsdl'
But I dont think it is working correct
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
我猜你的控制器没有命名为控制器。如果是,我会重命名它并更改上面的路线。
Try this:
I'm guessing that your controller is not named controller. If it is, I'd rename it and change the above route as well.
我还没有找到一个好的解决方案来将 Rails 2 参数化 :controller 和 :action 通用路由转换为更明确的 Rails 3+ 格式。我所要做的就是检查应用程序中的每个排列,并为我需要支持的所有内容添加明确的路线。例如,在您的情况下,如果您有 3 个支持 wsdl 操作的控制器,我将使用 match 或 get 为每个控制器添加一条新路由。
假设您有一个 foo_controller、bar_controller 和 blah_controller 都支持 wsdl 操作,它可能如下所示:
当您需要支持控制器上使用 :action 的每个操作时,这会变得更有趣。
如果有人有更好的方法,我很乐意(并且渴望)听到更好的方法。
I haven't found a good solution to converting Rails 2 parameterized :controller and :action generic routes to the more explicit Rails 3+ format. What I've had to do is go through every permutation in my app and add an explicit route for everything I needed to support. For example, in your case, if you had 3 controllers that supported the wsdl action, I'd add a new route for each using either match or get.
Here's what it might look like, assuming you had a foo_controller, bar_controller, and a blah_controller that all support the wsdl action:
This gets even more fun when you need to support every action on a controller when they use :action.
If anyone has a better method, I'm open (and eager) to hear of a better way.