使用:
jquery3-autocomplete gem at 1.0.5
jquery-rails gem at 1.0.19
mysql2 gem在0.2.7
autocomplete gem在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 gem。开发环境使用mysql。这解决了我的问题 - 我希望它可以帮助别人。
group :production do
gem 'pg'
end
答案 0 :(得分:0)
我正在使用Heroku所以我偶然在我的开发环境中加载了PostgreSQL gem。开发环境使用mysql。这解决了我的问题 - 我希望它可以帮助别人。
group :production do
gem 'pg'
end