How-to: Deploy Ruby on Rails in a subdirectory and not in root

Normally one would deploy their rails application in the root directory (top-level) ie where the domain is, for example…

However, you may want to deploy your app in a subdirectory such as…

You may want to do this if you want to deploy several applications on the same domain or temporarily for testing purposes. So heres what to do. Naviagate to the environment.rb file found here…

root | configuration | environment.rb

Open the file in your favourite text editor. Add the relative url configuration to your config as shown below. I added it to the end of the do statement. do |config|
  config.action_controller.relative_url_root = "/your_app"

This setups the environment for rails to now run with url root of your_app.

Happy deploying!