ActiveRecord没有正确引用查询

时间:2013-05-03 11:32:16

标签: ruby-on-rails postgresql activerecord

我的黄瓜方案以下列方式失败:

  Scenario: I can create a blog post                  # features/blog/create_blog_post.feature:6
    Given I am the super admin                        # features/step_definitions/post_steps.rb:1
      PG::Error: ERROR:  syntax error at or near "."
      LINE 1: SELECT  "user".* FROM "user"  ORDER BY user.updated_at desc ...
                                                         ^
      : SELECT  "user".* FROM "user"  ORDER BY user.updated_at desc LIMIT 1 (ActiveRecord::StatementInvalid)
      (eval):8:in `instance_eval'
      (eval):8:in `dashboard'
      ./features/support/world_extensions.rb:51:in `sign_in_with'
      ./features/step_definitions/post_steps.rb:2:in `/^I am the super admin$/'
      features/blog/create_blog_post.feature:7:in `Given I am the super admin'
    When I create a blog post                         # features/step_definitions/post_steps.rb:5
    Then that blog post should show up on the website # features/step_definitions/post_steps.rb:14

显然,这里的问题是user未被正确引用(实际上称为user,而不是users)。知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

您的测试数据库似乎不是最新的。首先尝试rake db:test:prepare