I have a rails app running sqlite3 in development and pg in production, currently running on Heroku. I am getting an error on my heroku app. I have a column called 'archived' which starts out as nil until the user pushes a button, then the current time gets written into the cell. Then all messages where archived != nil is then ordered by most recent.
Below is a portion of my heroku log:
2013-05-07T22:00:31.775149+00:00 app[web.1]: Completed 500 Internal Server Error in 34ms 2013-05-07T22:00:31.785541+00:00 app[web.1]: 2013-05-07T22:00:31.785541+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: invalid input syntax for type timestamp: "" 2013-05-07T22:00:31.785541+00:00 app[web.1]: LINE 1: ... "messages".* FROM "messages" WHERE (archived <> '') ORDER ... 2013-05-07T22:00:31.785541+00:00 app[web.1]: ^ 2013-05-07T22:00:31.785541+00:00 app[web.1]: : SELECT "messages".* FROM "messages" WHERE (archived <> '') ORDER BY archived desc LIMIT 10):
This tells me that the issue is this line of code from my controller:
@archived_messages = Message.where("archived <> ''").limit(10).order('archived desc')
What should I change this code to so that it works in both sqlite3 and pg?
Thanks in advance.
Got it!
@archived_messages = Message.where("archived IS NOT NULL").limit(10).order('archived desc')
source: Runs locally with SQLite, but on Heroku: PGError: ERROR: syntax error at or near "NULL"