TL;DR: how can I have Rails 3 route without a path prefix, but write URLs with the prefix?
Let's say you have a rails 3 app with a controller for bars. You deploy it to your WebFaction website with a URL path of /foo. To get a list of bars, you go to http://host.com/foo/bars. The web server routes the path /foo to passenger, and when the request gets to rails' routing engine, it looks like a request for /bars.
Now you want to link to your list of bars, so you write
In Rails 3, this is achievable using a scope:
Now both /foo/foo/bars and /foo/bars will route to BarsController. Unfortunately,
Is there a way to write the
I was finally able to get it to work with:
Basically, this creates the routes with and without the path prefix. So with this approach, both
answered Jul 12 '12 at 18:16