Using:
jquery3-autocomplete gem at 1.0.5
jquery-rails gem at 1.0.19
mysql2 gem at 0.2.7
The autocomplete gem works as expected in jquery but I receive a mysql2 error:
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)
Anyone have any ideas? I’m a little stumped on this one. It WAS working before and broke recently. Most likely because of a bundle update I ran, but I can’t backtrace what the culprit was or confirm that it’s actually the issue.
EDIT: FIXED ISSUE:
I’m using Heroku so I had the PostgreSQL gem loading in my dev environment by accident. The dev environment uses mysql. This solved my problem – I hope it helps someone else.
group :production do
gem 'pg'
end
I’m using Heroku so I had the PostgreSQL gem loading in my dev environment by accident. The dev environment uses mysql. This solved my problem – I hope it helps someone else.