使用rails3 consol
时出现此错误消息IRB(主):018:0> WebtrisulMenu.find(1)
NoMethodError:未定义的方法eq' for nil:NilClass
method_missing'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/whiny_nil.rb:48:in
来自/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:299:infind_one'
find_with_ids'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:289:in
来自/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:107:infind'
发现'
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:instart'
开始'
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
请帮我摆脱这个?
答案 0 :(得分:0)
您的WebtrisulMenu
课程有问题。当nilsclass错误告诉我,当加载Rails环境时,它没有被初始化。
因此,您无法在WebtrisulMenu
模型上找到。
查看此模型中的任何错误,如果您无法自己弄明白,请在此处发布文件内容。