Reputation: 7892
I trying to write some condition to pull out objects from database:
Page.where(published: true).where("`published_at` <= current_date()").where("`publication_end` IS NULL OR `publication_end` > current_date()")
When i enter it in the rails console i have the following error:
SELECT "pages".* FROM "pages" WHERE "pages"."published" = 't' AND (`published_at` <= current_date()) AND (`publication_end` IS NULL OR `publication_end` > current_date())
PG::SyntaxError: ERROR: syntax error at or near "("
LINE 1: ...blished" = 't' AND (`published_at` <= current_date()) AND (`...
^
: SELECT "pages".* FROM "pages" WHERE "pages"."published" = 't' AND (`published_at` <= current_date()) AND (`publication_end` IS NULL OR `publication_end` > current_date())
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "("
LINE 1: ...blished" = 't' AND (`published_at` <= current_date()) AND (`...
^
: SELECT "pages".* FROM "pages" WHERE "pages"."published" = 't' AND (`published_at` <= current_date()) AND (`publication_end` IS NULL OR `publication_end` > current_date())
I,m Using Postgresql Please help.
Upvotes: 0
Views: 5011
Reputation: 7892
i write:
Page.where(published: true).where("published_at <= current_date").where("publication_end IS NULL OR publication_end > current_date")
and now i ok
Thanks :)
Upvotes: -1
Reputation: 124479
Remove the parentheses:
# select current_date();
ERROR: syntax error at or near "("
LINE 1: select current_date();
# select current_date;
date
------------
2014-02-19
(1 row)
Upvotes: 2