Select2导致未定义的方法`[]'为nil:application.css.scss中的NilClass

时间:2013-08-20 16:34:34

标签: ruby-on-rails select2-rails

我不得不在版本'3.3.2'上强制使用gem锁来删除以下错误。

undefined method `[]' for nil:NilClass
  (in /home/funk/rails_projects/goodsounds.org/app/assets/stylesheets/application.css.scss)

从我的application.css.scss中删除*= require select2之后我没有错误,但不幸的是,这不是解决方案,因为我需要使用gem。

请帮忙。我需要升级!

我的application.css.scss文件

/*
 *= require dataTables/jquery.dataTables.bootstrap
 *= require select2
 *= require chosen
 *= require font-awesome
 *= require ajax_pagination
 *= require_self
 *= require_tree .
*/

@import 'bootstrap';
@import 'bootstrap-responsive';
@import "font-awesome";

完全追踪

rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/funk/.rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
undefined method `[]' for nil:NilClass
  (in /home/funk/rails_projects/goodsounds.org/app/assets/stylesheets/application.css.scss)
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:32:in `resolver'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/helpers.rb:25:in `image_url'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/funcall.rb:112:in `_perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/node.rb:40:in `perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `block in _perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/list.rb:70:in `_perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/script/node.rb:40:in `perform'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `map'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/visitors/perform.rb:7:in `visit'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/tree/root_node.rb:20:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/engine.rb:315:in `_render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-3.2.10/lib/sass/engine.rb:262:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sass-rails-3.2.6/lib/sass/rails/compressor.rb:12:in `compress'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/compressors.rb:74:in `compress'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processing.rb:243:in `block in css_compressor='
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:19:in `block in compile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `load'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/funk/.rvm/rubies/ruby-1.9.3-p374/bin...]
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:55:in `block in create_shell_runner'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils.rb:82:in `ruby'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `ruby'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/funk/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/funk/.rvm/gems/ruby-1.9.3-p374@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `load'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/rake:23:in `<main>'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/ruby_noexec_wrapper:14:in `eval'
/home/funk/.rvm/gems/ruby-1.9.3-p374@goodsounds/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile

1 个答案:

答案 0 :(得分:1)

Dunno如果你仍然坚持这个问题,但它是一个红宝石bug

我的解决方法是将select2 css文件更改为.erb,并将所有asset-url替换为

url(<%= asset_path "..." %>)