2012-10-01 180 views
0

我正在將應用程序從Rails 3.0.3升級到3.2.8。試圖讓資產預先編譯。我得到這個輸出:Rails 3.2.8 - 預編譯資產失敗

$ bundle exec rake assets:precompile 
/usr/local/rvm/rubies/ruby-1.9.2-p320/bin/ruby /usr/local/rvm/gems/[email protected]/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets 
rake aborted! 
no such file to load -- sass/rails/compressor 
    (in /home/danb/Documents/Projects/pier-admin/pier-admin/app/assets/stylesheets/application.css) 

Tasks: TOP => assets:precompile:primary 
(See full trace by running task with --trace) 
rake aborted! 
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.2-p320/bin/...] 

Tasks: TOP => assets:precompile 
(See full trace by running task with --trace) 

是相對較新的,我對這個問題是不知所措。我之前沒有使用過資產,並且在升級過程中我儘量做到最低限度。該應用程序在開發中工作。任何幫助,將不勝感激。

資產組是:

group :assets do 
    gem 'sass' 
    gem 'coffee-script' 
    gem 'uglifier' 
end 

application.css只有

/* 
* 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 . 
*/ 

回答

1

的:資產組不會在生產安裝,所以你很可能缺少這些寶石和耙失敗。

一種選擇是在開發時進行預編譯,將文件提交到/ public並將它們推送到生產服務器。

另一種是在application.rb中像懶洋洋地初始化資產:

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    # Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    Bundler.require(:default, :assets, Rails.env) 
end 
+0

謝謝,芥蘭!這清除了事情。我在開發中進行了預編譯,並將它們推送到存儲庫,然後推送到服務器,一切正常。 –