File Not Found Error When Changing style.css.scss to style.css.scss.erb

假如想象 提交于 2019-12-13 08:24:43

问题


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!


回答1:


I have had this issue in the past and could only solve it by putting my image file in the public folder.



来源:https://stackoverflow.com/questions/37488785/file-not-found-error-when-changing-style-css-scss-to-style-css-scss-erb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!