Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 在Rails查询中获取数据库错误_Ruby On Rails 3_Postgresql - Fatal编程技术网

Ruby on rails 3 在Rails查询中获取数据库错误

Ruby on rails 3 在Rails查询中获取数据库错误,ruby-on-rails-3,postgresql,Ruby On Rails 3,Postgresql,在我试图设置的rake任务中,PostgreSQL中的一个查询出错 posts = Post.where("status IS ? AND publish_on < ?", 'queued', Time.now) posts=Post.where(“状态为?并在

在我试图设置的rake任务中,PostgreSQL中的一个查询出错

  posts = Post.where("status IS ? AND publish_on < ?", 'queued', Time.now)
posts=Post.where(“状态为?并在<?”,“排队”,时间为现在)
以下是错误:

PGError: ERROR:  syntax error at or near "'queued'"
    LINE 1: SELECT "posts".* FROM "posts"  WHERE (status IS 'queued' AND...
                                                            ^
    : SELECT "posts".* FROM "posts"  WHERE (status IS 'queued' AND publish_on < '2012-04-29 23:44:06.423516')
PGError:ERROR:syntax ERROR在“'queued'”处或附近
第1行:从“posts”中选择“posts”。*其中(状态为“排队”,并且。。。
^
:从“帖子”中选择“帖子”。*其中(状态为“排队”,发布时间为<'2012-04-29 23:44:06.423516')

起初我以为是引号,但更改引号不起作用。现在我想可能是我如何构造and子句的?

仅用于与
进行比较。您可能想要
=

posts = Post.where("status = ? AND publish_on < ?", 'queued', Time.now)
posts=Post.where(“status=”和publish_on<?”,“queued”,Time.now)