我刚刚使用this将rails应用程序db从sqlite3切换到mysql2,这似乎是正常的。
但当我启动我的应用程序时,我现在得到的是:

A ActionView::Template::Error occurred in pages#dashboard:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 1) LIMIT 20 OFFSET 0' at line 1: SELECT `tickets`.* FROM `tickets` WHERE (archived == 1) LIMIT 20 OFFSET 0
activerecord (3.0.3) lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'

不知道在哪里可以让它正常工作。任何帮助都将不胜感激。谢谢!

最佳答案

试试这个:

# Notice single = vs ==
WHERE (archived = 1)

更新
最终
scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)

这很有效。谢谢!

09-25 18:53