0

我有一个在开发中运行 sqlite3 和在生产中运行 pg 的 rails 应用程序,目前在 Heroku 上运行。我的 heroku 应用程序出现错误。我有一个名为“存档”的列,它从 nil 开始,直到用户按下按钮,然后当前时间被写入单元格。然后所有已归档 != nil 的消息都按最新排序。

以下是我的heroku日志的一部分:

2013-05-07T22:00:31.775149+00:00 app[web.1]:在 34 毫秒内完成 500 个内部服务器错误 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: 类型时间戳无效的输入语法:"" 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存档 desc 限制 10):

这告诉我问题出在我的控制器中的这行代码:

@archived_messages = Message.where("archived <> ''").limit(10).order('archived desc')

我应该将此代码更改为什么,以便它在 sqlite3 和 pg 中都可以使用?

提前致谢。

4

1 回答 1

0

知道了!

@archived_messages = Message.where("archived IS NOT NULL").limit(10).order('archived desc')

来源:使用 SQLite 在本地运行,但在 Heroku 上:PGError: ERROR: syntax error at or near "NULL"

于 2013-05-07T22:48:09.110 回答