ruby-on-rails Mysql2::Error:您的SQL语法中存在错误

bvjveswy  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(225)

我只是用this把我的rails应用数据库从sqlite3切换到mysql 2,看起来工作正常。
但是当我启动我的应用程序时,我得到了这个:

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'

字符串
不知道在哪里可以让这个正常工作。任何帮助将不胜感激。谢谢!

wlsrxk51

wlsrxk511#

试试这个:

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

字符串

更新结束了做

scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)


效果很好。谢谢!

相关问题