I'm trying to install the twitter-typeahead-rails
gem into my app. I've followed several different tutorials but all of them result in errors.
Does anyone have a working example of this gem?
I'm trying to install the twitter-typeahead-rails
gem into my app. I've followed several different tutorials but all of them result in errors.
Does anyone have a working example of this gem?
Specify gem as dependency in your
Gemfile
:Require typeahead files in your manifest:
Javascript:
View:
Routes:
Controller:
GET request to /typeahead/%QUERY returns json in the form of:
The accepted answer is not completely correct.
There seem to be 2 different gems doing roughly the same thing:
bootstrap-multiselect-rails
is currently on version 0.9.9 in the gem repository and has a different asset require structure as mentioned in the post. This gem's assets need to be included as:More on Git: https://github.com/benjamincanac/bootstrap-multiselect-rails
Alternatively, there is the
twitter-typeahead-rails
gem, currently on version 0.11.1 which seem to need to be used and included as described in the rest of the accepted answer.More on Git: https://github.com/yourabi/twitter-typeahead-rails
Both gems seem to be last updated about 5-6 months ago at the moment of writing this.
Finally, the remote URL specified in the Bloodhound JS is incorrect:
Needs to be
Hopefully this helps someone