0
使用:jQuery的自動完成創業板失敗,並在Rails的mysql2錯誤應用
jquery3,自動完成的寶石在1.0.5
jQuery的軌道寶石在1.0.19
mysql2寶石在0.2.7
自動完成寶石將按預期在jQuery的,但我收到一個錯誤mysql2:
Job Load (0.4ms) SELECT jobs.id, jobs.title FROM `jobs` WHERE (LOWER(jobs.title) ILIKE 'te%') ORDER BY jobs.title ASC LIMIT 10
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 'ILIKE 'te%') ORDER BY jobs.title ASC LIMIT 10' at line 1: SELECT jobs.id, jobs.title FROM `jobs` WHERE (LOWER(jobs.title) ILIKE 'te%') ORDER BY jobs.title ASC LIMIT 10
Completed 500 Internal Server Error in 131ms
ActiveRecord::StatementInvalid (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 'ILIKE 'te%') ORDER BY jobs.title ASC LIMIT 10' at line 1: SELECT jobs.id, jobs.title FROM `jobs` WHERE (LOWER(jobs.title) ILIKE 'te%') ORDER BY jobs.title ASC LIMIT 10):
# gemfile
gem 'jquery-rails'
gem 'rails3-jquery-autocomplete'
# jobs_controller.rb
autocomplete :tag, :name
autocomplete :job, :title
# routes.rb
resources :jobs do
get :autocomplete_tag_name, :on => :collection
get :autocomplete_job_title, :on => :collection
end
#chrome console
GET http://localhost:3000/jobs/autocomplete_job_title?term=te 500 (Internal Server Error)
f.support.ajax.f.ajaxTransport.sendjquery.min.js:4
f.extend.ajaxjquery.min.js:4
f.each.f.(anonymous function)jquery.min.js:4
f.extend.getJSONjquery.min.js:4
a.railsAutocomplete.fn.extend.init.a.autocomplete.sourceautocomplete-rails.js:16
d.widget._searchjquery-ui.min.js:326
d.widget.searchjquery-ui.min.js:326
(anonymous function)
任何人有任何想法?我有點難過這個。它最近在工作並最近破產。最有可能是因爲我跑了bundle update
,但我無法追溯罪魁禍首是什麼或確認它實際上是問題。
編輯:固定問題: 我使用Heroku,所以我在我的開發環境中偶然加載了PostgreSQL寶石。開發環境使用mysql。這解決了我的問題 - 我希望它可以幫助別人。
group :production do
gem 'pg'
end