资产不会编译生产

时间:2016-06-22 15:40:59

标签: ruby ruby-on-rails-4 heroku sprockets

我一直试图在生产中预编译资产,但它一直在破碎。

我试过

  RAILS_ENV=production rake assets:precompile

得到了:

I, [2016-06-22T15:59:02.648161 #1680]  INFO -- : Writing /Users/johndoe/Documents/be/Chak/public/assets/application-3b7afc621ec8ef5d713fe45400021fdd80041418493b774e248da6a1fcfc4052.js
I, [2016-06-22T15:59:02.939980 #1680]  INFO -- : Writing /Users/johndoe/Documents/be/Chak/public/assets/application-3b7afc621ec8ef5d713fe45400021fdd80041418493b774e248da6a1fcfc4052.js.gz
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
JohnDoesMBP:Chak johndoe$ RAILS_ENV=production rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/johndoe/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/sass_processor.rb:278:in `sprockets_context'
/Users/johndoe/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/sass_processor.rb:124:in `asset_path'
/Users/johndoe/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/sass_processor.rb:200:in `font_path'
/Users/johndoe/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sass-3.4.21/lib/sass/script/tree/funcall.rb:140:in `_perform'

任何人都有想法,有什么不对?

我的production.rb文件如下所示:

config.serve_static_files = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.log_level = :debug

任何帮助将不胜感激。提前谢谢!

的Gemfile:

ruby '2.2.2'
gem 'figaro', '~> 1.0.0'
gem 'rails_12factor', group: :production
gem 'puma'
gem 'nifty-generators', :group => :development
gem 'table_print'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'omniauth-google'
gem 'devise'
gem 'devise_invitable'
gem 'carrierwave', :github => 'satoruk/carrierwave', :ref => '43179f94d6a4e62f69e812f5082d6447c9138480'
gem 'rmagick', require: false
gem 'rails', '4.2.4'
gem 'pg'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'activemerchant'
gem 'paypal-sdk-rest'
gem 'paypal-sdk-adaptivepayments'

group :development, :test do
  gem 'byebug'
  gem 'quiet_assets'
  gem 'pry-rails'
  gem 'thin'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

1 个答案:

答案 0 :(得分:0)

如果您正在使用Heroku,则不需要预编译自己的资源,当您推送到服务器时,它将自动完成。