Ruby on rails 3 在Rails查询中获取数据库错误
在我试图设置的rake任务中,PostgreSQL中的一个查询出错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(“状态为?并在
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)