Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails路由和url缩短器_Ruby On Rails_Ruby_Url Shortener_Vanity - Fatal编程技术网

Ruby on rails rails路由和url缩短器

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

我使用虚荣宝石的电子邮件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 :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]