Deploying Rails 3 apps to a subdirectory with the asset pipeline
When precompiling assets on deployment Rails has no idea where your application is hosted. If you are running your application on a subdirectory all of your image-url
directives in your CSS for asset images will construct incorrect URLs.
The solution is to set the RAILS_RELATIVE_URL_ROOT
environment variable when precompiling assets (either on the server or locally if you are checking in assets to Git).
For Capistrano this means adding the following line to your deploy.rb
file:
default_environment['RAILS_RELATIVE_URL_ROOT'] = '/my-app'
Written by David Somers
Related protips
1 Response
Couldn't get this to work until I ran rm -rf tmp/cache
before changing the RAILS_RELATIVE_URL_ROOT
variable -- took me a while to find that as the cause. Maybe that will help someone else.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#