耙子流产了! nil的未定义方法`each':NilClass

时间:2014-06-30 05:58:50

标签: ruby-on-rails ruby ubuntu

每次运行“sudo bundle exec rake snorby:setup”时,我都会收到此错误。

另外,我对此很新,也无法弄清楚我做错了什么。如果需要更多信息以便充分回答这个问题,请告诉我。

完整跟踪:

ciscadet@farnsworth:/var/www/snorby$ sudo bundle exec rake snorby:setup
No time_zone specified in snorby_config.yml; detected time_zone: US/Eastern
rake aborted!
undefined method `each' for nil:NilClass

Tasks: TOP => snorby:setup => environment
(See full trace by running task with --trace)
ciscadet@farnsworth:/var/www/snorby$ sudo bundle exec rake snorby:setup --trace
No time_zone specified in snorby_config.yml; detected time_zone: US/Eastern
** Invoke snorby:setup (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `each' for nil:NilClass
/var/www/snorby/vender/cache/ruby/1.9.1/gems/dm-rails-1.2.1/lib/dm-rails/setup.rb:11:in `setup'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/dm-rails-1.2.1/lib/dm-rails/railtie.rb:90:in `block in <class:Railtie>'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/lazy_load_hooks.rb:34:in `call'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/lazy_load_hooks.rb:42:in `each'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:30:in `instance_exec'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:30:in `run'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:54:in `each'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:54:in `run_initializers'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:96:in `initialize!'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/snorby/config/environment.rb:3:in `<top (required)>'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in `require'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in `block in require'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in `require'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:83:in `require_environment!'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:203:in `block (2 levels) in initialize_tasks'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/var/www/snorby/vender/cache/ruby/1.9.1/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/var/www/snorby/vender/cache/ruby/1.9.1/bin/rake:23:in `load'
/var/www/snorby/vender/cache/ruby/1.9.1/bin/rake:23:in `<main>'
Tasks: TOP => snorby:setup => environment

1 个答案:

答案 0 :(得分:0)

无方法

错误在于:

  

snorby_config.yml中没有指定time_zone;检测到time_zone:   美国/东方耙子中止了!

no method error基本上意味着您调用.each的对象不存在。大多数人认为方法调用是问题所在,但事实恰恰相反 - 缺少object

解决此问题的方法是确保定义object。通常,您可以通过定义相关的@instance variable来实现这一目标。但是,您目前的问题似乎是snorby_config.yml

-

<强> snorby_config.yml

根据他们的github example - snorby_config.yml,您应该将其填入config/snorby_config.yml

查看您的错误日志,似乎Rails无法调用snorby:setup,从而导致您看到的其他错误。要解决此问题,您需要确保正确设置snorby

$ rake snorby:setup