Mysql2 ::错误:您的SQL语法错误
我刚刚使用this将我的rails应用程序数据库从sqlite3切换到mysql2,并且似乎正常工作。Mysql2 ::错误:您的SQL语法错误
但是当我开始了我的应用程序,现在我得到这样的:
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)
这伟大的工作。谢谢!
所以像这样:'''scope:not_archived,where('archived ==?',1)'''?? – Marc 2012-02-23 01:53:35
范围:not_archived,其中('archived =?',1) – 2012-02-23 01:54:18
交替地,作用域:not_archived,其中(:archived => 1) – 2012-02-23 01:54:37
当我导航到rails管理员,并尝试编辑我的users.do你有什么想法时,我有这个错误? – 2017-09-05 10:33:00