0

I have a set of products that I want available with the full file path and helper functions, but I want to shorten their URLs. Like this:

http://example.com/p/fb

And I would like that to route like this:

product_foobar GET    /p/fb(.:format)                products/foobar#show

Product is just a namespace, so I know I can namespace it in the routes:

namespace :product do
  resource :foobar
end

But that results in this route:

product_foobar GET    /product/foobar(.:format)      product/foobars#show

Is it possible to just alias the URL like that?

kid_drew
  • 3,857
  • 6
  • 28
  • 38
  • http://stackoverflow.com/questions/4696229/as-in-rails-routes-rb I guess this could be helpful, having a named route – Claudiu S Sep 18 '13 at 19:40

1 Answers1

0

Found it. Add this line to routes.rb:

get '/p/fb' => "product/foobar#show"
kid_drew
  • 3,857
  • 6
  • 28
  • 38