问题描述:

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?

网友答案:

Found it. Add this line to routes.rb:

get '/p/fb' => "product/foobar#show"
相关阅读:
Top