新手问题 Rails route URL 中的带点的情况如何处理?

scott · 2013年05月27日 · 最后由 scott 回复于 2013年05月27日 · 2428 次阅读

现在遇到这样一个问题: 代码如下: <% map.tag_list.each do |tag| %> <%= link_to tag, tag_maps_path(:tag_name => tag) %> <% end %> 解析之后有的链接会是:http://xxx.xxx.com/maps/tag/pm2.5 的一个链接。 这里 url 中的“.5”会被截断! 有遇到类似问题的吗?怎么解决的?

routes.rb

resources :maps do
  collection do
    get :tag, constraints: { id: /[\w\d\.\-\_]+/i }
  end
end
需要 登录 后方可回复, 如果你还没有账号请 注册新账号