I’ve just configured Rails to run in a subfolder on a client’s website. Ran into a few issues, that are worth documenting:
In this configuration, you can visit the Rails site by visiting something like http://www.hostname.com/coolsite/
1. There is a Rails bug (ticket 10913) that effects links to assets. I have a link to our combined stylesheets defined as:
The bug is that Rails looks for all of your stylesheets in /public/coolsite/stylesheets/*.css, where ‘coolsite’ is the name of your subdirectory. Obviously, it should not be including the ‘coolsite’ folder in the path.
The workaround I use, is to create a soft link after capistrano deploys the code to our production server. I added this to my /config/deploy.rb file.
after “deploy:update”, “create_apache_prefix_link”
Now, whenever you do a cap:deploy, a soft link will be created in your public software, and this will allow Rails to resolve the stylesheet (and other asses files) in the faulty path. When the ticket is fixed, just remove the capistrano task.