Css Background Images For Rails Production Environment

Posted By Weston Ganger

I was originally using the css rule background:url('image.png'); this does not work in Rails for production

The fix is to use one of the following:

background:image-url('image.png');

or

background:asset-url('image.png');

Take note that this only works when the image is located in app/assets/images/

If the image is an attachment to a model and is not being stored in the assets directory then you must use the original:

background:url('image.png');

Article Topic:Software Development - HTML / CSS

Date:July 07, 2014