I've an issue with PostgreSQL using Rails. I have a table with datetime "from" and "to". In my controller I got the following:
@running = Model.where("'to' > ?", Time.now)
@finished = Model.where("'to' < ?", Time.now)
I already learned that I have to escape the "to", because it's a SQL statement. The problem now is that with MySQL and SQLite I can escape it with ` , so in my development environment (sqlite), it's working with:
.where("`to` > ?", Time.now)
And it actually works correct in the app.
But my production environment is Postgres, and Postgres doesn't support ``, and '' isn't working apparently because it doesn't matter what the entrys "to" is, it's always displaying the @running one even though it should be @finished.
What's wrong?
Thanks!!
Model.where("table_name.to > ?", Time.now)?Time.now? Second, why not useModel.where(to: Time.now..5.years.ago)or whatever range you're actually trying to showcase?