我無法使Rails 3.1資產管道預編譯工作在生產模式下。它總是失敗的SCSS中引用的圖片有如下錯誤:Ruby on Rails 3.1資產:預編譯和圖像
$ 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)
但是,當我看在公共/資產目錄,圖像是存在的,所以它是預編譯:
$ 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中圖像的URL幫手,只是URL(「/資產/ rails.png」),預編譯工作正常,並manifest.yml文件是g在公共/資產上擁有。有趣的是:如果我將SCSS更改回image-url('rails.png')並運行另一個預編譯,它仍然有效(我猜是因爲圖像現在已經列在清單文件中)。
我在這裏做錯了什麼?我真的不想忽視輔助方法(因爲使用它們是你應該這樣做的方式,對吧?),我絕對不想手動創建清單文件...
剛剛更新到Rails 3.1.1rc1建議在github問題,它的工作原理:-) – fwalch
這個答案似乎不好,因爲這個原因:http://stackoverflow.com/questions/8821864/config-assets-compile-真在護欄 - 生產 - 爲什麼 - 不 – Ringo