Mysql2 ::错误:您的SQL语法中有错误

我只是用它将我的rails app 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) 

这很有效。 谢谢!