带有包含斜杠 (/) 的参数的 Rails 路由 [英] Rails routing with a parameter that includes slash(/)
本文介绍了带有包含斜杠 (/) 的参数的 Rails 路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想设置路由如下
/url/http://google.com
到urls
控制器和index
操作.
/url/http://google.com
tourls
controller andindex
action.
我现在在 routes.rb
中有:
match "urls/:url" => "urls#index"
路由似乎不起作用,因为 :url
中的斜线.
The routing doesn't seem to work because the slashed in :url
.
推荐答案
你可以做类似的事情
match "urls/:url" => "urls#index", :constraints => {:url => /.*/}
在 Rails 2.3 中,它可能在 Rails 3 中工作,允许您匹配 :url 中的/(虽然,我目前无法对此进行测试.)
in Rails 2.3 which may work in Rails 3 to allow you to match the / in the :url (although, I can't test this at the moment.)
这篇关于带有包含斜杠 (/) 的参数的 Rails 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文