Arti
Arti

Reputation: 407

Rails3 Autocomplete - Object has no method 'autocomplete'

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?

Upvotes: 1

Views: 1386

Answers (3)

ferhan
ferhan

Reputation: 2779

I had similar issues and resolved, then posted some comments to this question. You may want to check out.

Upvotes: 0

user979587
user979587

Reputation: 263

The problem is that your not loading jquery-ui, you need to add the js and css require if using asset pipeline.

Upvotes: 1

bbonamin
bbonamin

Reputation: 30803

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

Upvotes: 1

Related Questions