我正在尝试在本地编译我的资产,所以我可以确保在推送到heroku时没有问题。在本地我的视图看起来很完美,但在heroku上它没有加载我的所有资产。当我运行RAILS_ENV=production bundle exec rake assets:precompile
我得到以下错误,有什么想法吗?
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:278:in `sprockets_context'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:124:in `asset_path'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:137:in `asset_url'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:209:in `font_url'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/script/tree/funcall.rb:143:in `_perform'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/script/tree/node.rb:58:in `perform'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:397:in `visit_prop'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `block in visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:79:in `block in with_base'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:115:in `with_frame'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:79:in `with_base'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:504:in `block (2 levels) in visit_directive'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:504:in `map'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:504:in `block in visit_directive'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:181:in `with_environment'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:503:in `visit_directive'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `block in visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:79:in `block in with_base'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:115:in `with_frame'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/stack.rb:79:in `with_base'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `map'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:169:in `block in visit_children'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:181:in `with_environment'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:168:in `visit_children'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:188:in `visit_root'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:159:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:8:in `visit'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/root_node.rb:36:in `css_tree'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/tree/root_node.rb:20:in `render'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sass-3.4.22/lib/sass/engine.rb:281:in `render'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_compressor.rb:48:in `call'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_compressor.rb:28:in `call'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/loader.rb:60:in `block in load'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/loader.rb:44:in `load'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:47:in `load'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/base.rb:66:in `find_asset'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:142:in `block in find'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `each'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:140:in `find'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:185:in `compile'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-rails-3.1.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-rails-3.1.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/Users/admin/.rvm/gems/ruby-2.3.1@global/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/bin/ruby_executable_hooks:15:in `eval'
/Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
答案 0 :(得分:1)
gem open sprockets -v 3.7.0
并添加以下三行
puts '#'*30
puts path
puts '#'*30
to /Users/admin/.rvm/gems/ruby-2.3.1@ryansportfolio/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:124
然后,您将知道哪个文件导致错误,通常是由于缺少资产/图像文件或在css中使用函数asset-url
。 ( asset-url仅在scss中可用)