I am using vanity gem for email ab testing
in order to track clicks, I use vanity tutorial :
<%= link_to "see my page HERE", vanity_track_url_for(Vanity.context.vanity_identity, :metric, :controller => "controller" :action => "method", host => "myhost.com") %>
but I also use an url shortener to provides me perishable links (expires_at)
my rails routes contains :
get '/s/:id' => "shortened_urls#show"
I add into it :
resources :shortened_urls
so the vanity url_for is working when I use :
<%= 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) %>
but the url looks like myhost.com/shortened_urls/aX5DtE5z69A and I want to have myhost.com/s/aX5DtE5z69A
I know how to do it with url rewriting in apach host :
RewriteRule ^/shortened_urls/(.*)$ /s/$1 [R=301,NC,L]
but I would like to know if there is a shortcut in rails to do it :)