Ruby on rails rails路由和url缩短器
我使用虚荣宝石的电子邮件ab测试 为了跟踪单击,我使用了Vanite教程:Ruby on rails rails路由和url缩短器,ruby-on-rails,ruby,url-shortener,vanity,Ruby On Rails,Ruby,Url Shortener,Vanity,我使用虚荣宝石的电子邮件ab测试 为了跟踪单击,我使用了Vanite教程: <%= link_to "see my page HERE", vanity_track_url_for(Vanity.context.vanity_identity, :metric, :controller => "controller" :action => "method", host => "myhost.com") %> 我在此补充: resources :shortene
<%= link_to "see my page HERE", vanity_track_url_for(Vanity.context.vanity_identity, :metric, :controller => "controller" :action => "method", host => "myhost.com") %>
我在此补充:
resources :shortened_urls
因此,当我使用以下工具时,vanity url_正在工作:
<%= link_to "see my page HERE too", vanity_track_url_for(Vanity.context.vanity_identity, :metric, :controller => "shortened_urls", :action => "show", :host => "myhost.com", :id => @short.unique_key) %>
但是我想知道rails中是否有一个快捷方式可以做到这一点:)我只是测试一下重写规则,它就像一个符咒:注意:考虑到Ruby 1.9已经存在了很长时间了,
controller:'…',action:'…,…
样式的哈希声明要短得多,更简洁,并镜像在其他语言(如JavaScript)中所做的操作。Ruby 1.8中的“hash rocket”只有在键不是符号的情况下才有必要。
<%= link_to "see my page HERE too", vanity_track_url_for(Vanity.context.vanity_identity, :metric, :controller => "shortened_urls", :action => "show", :host => "myhost.com", :id => @short.unique_key) %>
RewriteRule ^/shortened_urls/(.*)$ /s/$1 [R=301,NC,L]