Jump to content

The ultimate community for Ruby on Rails developers.


Rails 4 autocomplete gem

  • Please log in to reply
No replies to this topic

#1 nick5745



  • Validating
  • 4 posts

Posted 05 May 2014 - 12:31 AM

I'm using this gem in my rails 4 application for autocompletion. I've followed the example very closely but have had no luck.

First I required these in my application.js is this enough or do I need to go and download jQuery UI? I have jquery-rails gemmed and in my public/javascripts folder have jquery.js jquery.min.js, and jquery_ujs.js files but no jquery.ui files.

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails

Next in my reviews controller (artist has a field called name):

class ReviewsController < ApplicationController

  autocomplete :artist, :name

in routes:

resources :reviews do
  get :autocomplete_artist_name, :on => :collection

and in my review form view:

<%= form_for(@review) do |f| %>
<%= f.autocomplete_field :artist, autocomplete_artist_name_reviews_path %>

When I try to type in artist names that already exist in my database, into the artist field of a review, nothing is autocompleted. I cleared browser history first to remove browser autocompletion and there is nothing working with the gem. I've spent a lot of time trying to figure this out and haven't got anywhere. Is it because my review has a field that is named artist as well?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users