I’m trying to implement autocomplete feature. I’ve looked through https://github.com/crowdint/rails3-jquery-autocomplete but I had to missed something because autocomplete field simply doesnt work.
When I’m trying to use autocomplete field nothing happens. Chrome JS console displays following error:
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
Controller:
class GamesController < ApplicationController
autocomplete :game, :title
routes.rb:
get "games/autocomplete_game_title" => "games#autocomplete_game_title", :controller => 'games', :action => "autocomplete_game_title", :via => :get, :as => "autogames"
View (games/edit):
<% form_for Game.new, :url => { :controller => "games", :action => "edit" } do |f| %>
<%= f.error_messages %>
<%= f.autocomplete_field :title, autogames_path %>
<%= f.submit "Edit" %>
<% end %>
Layout header:
<link href="/stylesheets/admin.css?1300378198" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery.js?1335792905" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1335792905" type="text/javascript"></script>
<script src="/javascripts/application.js?1335809045" type="text/javascript"></script>
<script src="/javascripts/autocomplete-rails.js?1336304504" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/smoothness/jquery-ui.css" media="screen" rel="stylesheet" type="text/css" />
I am completely confused, I’ve checked almost all combinations. Any suggestions what can be wrong?
I’ve run into many issues trying to use that gem with Rails > 3.0, I ended up using a straight Jquery-UI alternative, which is also easier. You might want to check out this link