Deploying a rails app on a suburi
I followed the instructions at the phusion passenger site and couldn't exactly get my app to run in a suburi - it kept trying to use that suburi when looking up routes.
I had found this:
WRONG!
-
ActionController::AbstractRequest.relative_url_root = "/rails"
However, there was a deprecation warning - and it seemed not to work at all. I then stumbled upon this which seems to work:
RIGHT!
-
config.action_controller.relative_url_root = "/rails"
If you care - my virtual host looks something like:
-
<virtualhost *:80>
-
ServerName localhost
-
DocumentRoot /Library/WebServer/Documents
-
RailsBaseURI /rails
-
-
</virtualhost>

Unlike running Mongrel with –prefix, with your solution image URI’s in stylesheets will be broken. How to solve that?
Well… then you’re using mongrel
. Actually I was thinking about this problem yesterday. I don’t see a good way except using either your webserver (apache, nginx) or changing your stylesheets. You *could* do that at build time to keep ‘em independent while you’re developing.
Thanks very much, this worked perfectly for me!
I’m also running phusion passenger to deploy my site to a sub-uri.
I already have one site running, and had fixed that one with a combination of statically prefixed routes, and adding the following to my production.rb to fix the stylesheet linking:
ActionController::Base.asset_host = “http://xx.com/specs”
With this solution, I still need to add that line. This seems to be a much better solution though, because if the site was moved to a different sub-uri, only two lines need to be changed!