Ruby on rails Rails 3.2.8-预编译资产失败

Ruby on rails Rails 3.2.8-预编译资产失败,ruby-on-rails,assets,Ruby On Rails,Assets,我正在将一个应用程序从Rails 3.0.3升级到3.2.8。正在尝试获取要预编译的资产。我得到这个输出: $ bundle exec rake assets:precompile /usr/local/rvm/rubies/ruby-1.9.2-p320/bin/ruby /usr/local/rvm/gems/ruby-1.9.2-p320@pier-admin-32/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROU

我正在将一个应用程序从Rails 3.0.3升级到3.2.8。正在尝试获取要预编译的资产。我得到这个输出:

$ bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-1.9.2-p320/bin/ruby /usr/local/rvm/gems/ruby-1.9.2-p320@pier-admin-32/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 . 
*/

资产组不会在生产中安装,因此您可能会丢失这些宝石,并且rake会失败

一种选择是在开发中预编译,在/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

谢谢,甘蓝!这就把事情弄清楚了。我在开发中预编译并将它们推送到存储库,然后推送到服务器,一切正常。