这是Vanity
gem生成的路线:
controller :vanities do
match ':vname' => :show, :via => :get, :constraints => {:vname => /[A-Za-z0-9\-\+]+/}
end
这是佣金路线:
GET /:vname(.:format) {:vname=>/[A-Za-z0-9\-\+]+/, :controller=>"vanities", :action=>"show"}
如何使用Rails链接助手直接链接到URL mydomain.com/vname
?
答案 0 :(得分:1)
从头到尾(抱歉,我现在没有时间对它进行测试):
controller :vanities do
match ':vname' => :show, :via => :get, :constraints => {:vname => /[A-Za-z0-9\-\+]+/}, :as => :vanity
end
你可以这样使用:
vanity_path(:vname => "marcamillion")