rails 3控制台错误

时间:2011-07-21 12:08:21

标签: ruby-on-rails-3

使用rails3 consol

时出现此错误消息
  

IRB(主):018:0> WebtrisulMenu.find(1)
  NoMethodError:未定义的方法eq' for nil:NilClass
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/whiny_nil.rb:48:in
method_missing'
      来自/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:299:in find_one'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:289:in
find_with_ids'
      来自/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:107:in find'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/base.rb:444:in
发现'
      来自(irb):18
      来自/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in
开始'
      来自/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:23:in <top (required)>'
from script/rails:6:in
要求'
      来自script / rails:6:in''

但是使用这样,它的工作正常

  

IRB(主):019:0&GT; WebtrisulContext.find(:all,:conditions =&gt; ['id = 1'])
  =&GT; WebtrisulContext id:1,name:“Primary”,internal_name:“”,description:“默认Web Trisul上下文”,slinkname:“root_ctx0”,webtrisul_dashboard_id:nil

请帮我摆脱这个?

1 个答案:

答案 0 :(得分:0)

您的WebtrisulMenu课程有问题。当nilsclass错误告诉我,当加载Rails环境时,它没有被初始化。

因此,您无法在WebtrisulMenu模型上找到。

查看此模型中的任何错误,如果您无法自己弄明白,请在此处发布文件内容。