Last Updated: February 25, 2016
·
695
· ashrocket

Rails Phusion Passenger Asset Path with Subdirectories - development mode

We're running a development project in Passenger, and we're running several apps in subdirectories. This works great but the other day a colleauge used the url funtion in a stylesheet like this:

footer {

margin: 0;
background:  url(/assets/footer-whole.png) no-repeat center center #c60651;
width: 100%;
height: 180px;

}

The app is running at:
http://oururl.com/shannon
so of course the css is looking for the asset at:

http://oururl.com/assets/footer-whole.png

When it should be looking at

http://oururl.com/shannon/assets/footer-whole.png

To fix this use asset_url in the css instead of url.

footer {

margin: 0;
background:  asset_url('footer-whole.png') no-repeat center center #c60651;
width: 100%;
height: 180px;

}
http://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-asset_path

1 Response
Add your response

correction added: must use asseturl, not assetpath

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip