我刚刚使用this将我的rails应用数据库从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'不确定在哪里可以让它正常工作。任何帮助都将不胜感激。谢谢!
发布于 2012-02-23 09:52:24
试试这个:
# Notice single = vs ==
WHERE (archived = 1)更新最终做了
scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)这样做效果很好。谢谢!
https://stackoverflow.com/questions/9406016
复制相似问题