【发布时间】:2011-11-30 15:40:32
【问题描述】:
我无法让 Rails 3.1 资产管道预编译在生产模式下工作。它总是在 SCSS 中引用的图像上失败,并出现如下错误:
$ bundle exec rake assets:precompile RAILS_ENV=production
rake aborted!
rails.png isn't precompiled
(in /home/florian/AssetTest/app/assets/stylesheets/application.css.scss)
但是当我查看 public/assets 目录时,图像在那里,所以它是预编译的:
$ ls public/assets | grep rails
rails-dd352fc2630e5f9aa5685ef1d7fe5997.png
本例中的 SCSS 文件只包含一些测试代码:
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
body {
background: #ffffff image-url('rails.png') no-repeat 0 center;
}
如果我不在 SCSS 中使用 image-url 助手,而只使用 url('/assets/rails.png'),预编译工作正常,并且在 public/assets 中生成 manifest.yml 文件。
有趣的是:如果我将 SCSS 改回 image-url('rails.png') 并运行另一个预编译,它仍然可以工作(我猜是因为图像现在已经在清单文件中列出)。
我在这里做错了什么?我真的不想忽视辅助方法(因为使用它们是你应该做的,对吧?),我绝对不想手动创建清单文件......
【问题讨论】:
标签: ruby-on-rails-3.1 asset-pipeline