I have been having a lot of trouble getting my background images to show up when I deploy my rails app to Heroku. I finally found this in the Heroku documentation:
In Rails 4 sprockets will only produce digest filenames. This means that you must use an ERB helper such as this to reference your assets:
<%= asset_path('logo.png') %>
Make sure to add a .erb extension to any files in app/assets that use an ERB helper. So application.css would need to be application.css.erb.
I tried renaming the style.css.scss
file with the offending background images to style.css.scss.erb
. This enabled me to change the link to the offending background images to:
background: <%= asset_path('bg-hero-000.jpg') %> no-repeat center center fixed;
However, I can't tell whether this was the magic bullet that will let Heroku actually display my images because I am now getting a File to import not found or unreadable:
error for that file.
I did some pretty extensive googling on this issue but can't seem to find a way out of the error. Any help or wisdom would be awesome!
I have had this issue in the past and could only solve it by putting my image file in the public folder.