我一直有一个 lot of trouble当我将 Rails 应用程序部署到 Heroku 时,让我的背景图片显示出来。我终于在 Heroku 文档中找到了这个:
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.
我尝试将带有违规背景图像的 style.css.scss
文件重命名为 style.css.scss.erb
。这使我能够将指向有问题的背景图片的链接更改为:
background: <%= asset_path('bg-hero-000.jpg') %> no-repeat center center fixed;
但是,我无法确定这是否是让 Heroku 实际显示我的图像的 Elixir ,因为我现在收到该文件的 要导入的文件未找到或无法读取:
错误。
我在这个问题上做了一些相当广泛的谷歌搜索,但似乎无法找到解决错误的方法。任何帮助或智慧都会很棒!
最佳答案
我过去遇到过这个问题,只能通过将我的图像文件放在公共(public)文件夹中来解决。
关于css - 将 style.css.scss 更改为 style.css.scss.erb 时找不到文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37488785/