“rake aborted!undefined method` [] ='for nil:NilClass”在cron job中运行rake时的消息

时间:2012-07-11 17:00:10

标签: ruby-on-rails rake

我是一名ROR noob,他继承了一个项目(Ruby版本1.9.3p0,Rails版本3.0.6,rake版本0.9.2),它作为cronjob的一部分执行rake。这已经输出“rake aborted!undefined method` [] ='nil:NilClass”到它的日志文件中。当我执行跟踪时,我得到以下输出:

rake aborted!
undefined method `[]=' for nil:NilClass
/var/www/nostos-source-illiad/lib/nostos-source-illiad/record.rb:48:in `block in charge!'
(eval):22:in `form_with'
/var/www/nostos-source-illiad/lib/nostos-source-illiad/record.rb:47:in `charge!'
/var/www/nostos/app/models/transaction.rb:65:in `block (2 levels) in sync!'
/var/www/nostos/app/models/transaction.rb:58:in `each'
/var/www/nostos/app/models/transaction.rb:58:in `block in sync!'
/var/www/nostos/app/models/transaction.rb:57:in `each'
/var/www/nostos/app/models/transaction.rb:57:in `sync!'
/var/www/nostos/lib/tasks/nostos.rake:17:in `block (2 levels) in <top (required)>'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin/rake:19:in `load'
/home/deployer/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin/rake:19:in `<main>'
Tasks: TOP => nostos:cron

我无法确定导致此问题的原因,并且正在寻找一些建议/方向。我认为这不是由报道here的同一问题引起的,但我不确定。任何帮助,将不胜感激。谢谢!

编辑: 可以找到nostos:rake的代码here

可以找到transaction.rb的代码here

1 个答案:

答案 0 :(得分:0)

进一步审核后,此问题似乎是由于传入的凭据集无效。解决此问题会删除上述消息。感谢您对此进行调查!