1

我剛剛使用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' 

不知道去哪裏找得到這個工作正常。任何幫助,將不勝感激。謝謝!

+0

當我導航到rails管理員,並嘗試編輯我的users.do你有什麼想法時,我有這個錯誤? – 2017-09-05 10:33:00

回答

4

試試這個:

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

更新 落得這樣做

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

這偉大的工作。謝謝!

+0

所以像這樣:'''scope:not_archived,where('archived ==?',1)'''?? – Marc 2012-02-23 01:53:35

+0

範圍:not_archived,其中('archived =?',1) – 2012-02-23 01:54:18

+0

交替地,作用域:not_archived,其中(:archived => 1) – 2012-02-23 01:54:37

相關問題