我刚刚使用this将我的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'
不确定在哪里可以正常使用。任何帮助,将不胜感激。谢谢!
答案 0 :(得分:4)
试试这个:
# Notice single = vs ==
WHERE (archived = 1)
<强>更新强> 结束了
scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)
这很有效。谢谢!