资产不会在生产中编译
Assets would not Compile in production
我一直在尝试在生产环境中预编译资产,但它一直在崩溃。
我试过了
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
如有任何帮助,我们将不胜感激。提前致谢!
宝石文件:
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
如果您使用的是 Heroku,则无需预编译您自己的资产,它会在您推送到服务器时自动完成。
我一直在尝试在生产环境中预编译资产,但它一直在崩溃。
我试过了
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
如有任何帮助,我们将不胜感激。提前致谢!
宝石文件:
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
如果您使用的是 Heroku,则无需预编译您自己的资产,它会在您推送到服务器时自动完成。