css - 将 style.css.scss 更改为 style.css.scss.erb 时找不到文件错误

标签 css ruby-on-rails heroku erb

我一直有一个 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/

相关文章:

ruby-on-rails - 如何删除和返回 ActiveRecord 关系对象中的第一个元素?

css - 将 Less 与 Visual Studio 2012 相结合

javascript - <a> 为 :hover or <div> with hover event for buttons?

ruby-on-rails - RSpec 应该 redirect_to 问题

heroku - 无法使用 Heroku 配置 Zerigo

javascript - Rails 5 + Webpacker 应用程序作为空白页面部署到 Heroku,没有失败

ruby-on-rails - Heroku & Rails - Varnish 只是偶尔缓存

html - 图像按列对齐

javascript - 创建 float 菜单

ruby-on-rails - cucumber :WAITINGajax:成功