I'm using rails 3 in production and development.
How do I use the asset_host path in css, for example with bac开发者_StackOverflow中文版kground-images?
I've tried:
.blerg{ background-image:url({asset_host}/images/blerg.gif); }
But it just comes out as that in the rendered document, is there anything special you have to do when including the css to get this to work?
If you are using Rails 3.1 Asset Pipline you can use the following in sass/scss
.blerg{ background-image: image-url(blerg.gif); }
The added advantage of this approach is that in production the css image will also contain the MD5 fingerprinting so you can setup a far future expires header on your background images and still have them expire if you make changes to them.
If you are serving css files from asset host all relative linked images in your css file are served from the same host.
If you just do /assets/blerg.gif it should work fine.
精彩评论