期待foo.rb定义Foo - 就我而言

时间:2011-07-22 16:41:21

标签: ruby-on-rails ruby ruby-on-rails-3

伙计们!我遇到了

Expected foo.rb to define Foo

问题。 我无法弄清楚到底是什么解决方案。我已经运行了rails控制台,并要求该模型具有更详细的错误代码。我明白了:

irb(main):002:0> c = Card_positions.find(1)
NameError: uninitialized constant Card_positions
        from (irb):2
        from C:/Programozas/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/
             rails/commands/console.rb:44:in `start'
        from C:/Programozas/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/
             rails/commands/console.rb:8:in `start'
        from C:/Programozas/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/
             rails/commands.rb:23:in `<top (required)>'
        from C:/Programozas/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_req
             uire.rb:59:in `require'
        from C:/Programozas/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_req
             uire.rb:59:in `rescue in require'
        from C:/Programozas/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_req
             uire.rb:35:in `require'
        from script/rails:6:in `<main>'

解决方案的想法?

1 个答案:

答案 0 :(得分:4)

对于名为card_positions的表,您应该执行CardPosition.find(1)