Skip to content

Deploying a rails app on a suburi

by Topper on February 7th, 2009

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!

RUBY:
  1. 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!

RUBY:
  1. config.action_controller.relative_url_root = "/rails"

If you care - my virtual host looks something like:

CODE:
  1. <virtualhost *:80>
  2.    ServerName localhost
  3.    DocumentRoot /Library/WebServer/Documents
  4.    RailsBaseURI /rails
  5.  
  6. </virtualhost>

From → Social Web

3 Comments
  1. José Ignacio permalink

    Unlike running Mongrel with –prefix, with your solution image URI’s in stylesheets will be broken. How to solve that?

  2. 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.

  3. Pat Murray permalink

    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!

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS