Problems with very basic auto_complete


I’m running rails 2.1 and have problems implementing even the very
basic auto_complete. It basically does nothing

Here’s what I have

auto_complete_for :general, :title

<% form_tag generals_path, :method => ‘get’ do %>
<%= text_field_with_auto_complete :general, :title, :autocomplete =>
“off” %>
<% end %>

I also have <%= javascript_include_tag :defaults %> in layout
tag included

no errors, just no response. can’t google out any solution :frowning:

thank you very much

the firebug console tells “Ajax.Autocompleter is not a constructor”
but then shows nothing when typing into the search field

come on guys, no help? :frowning:

You Need to add a function with name auto_complete_for_general_title
in tour controller which will query your database and the results.

Check the line in your view:

<%= text_field_with_auto_complete :general, :title, :autocomplete =>

should be title and not :title

You’ll also need to deal with the forgery protection in rails 2.1
the auto complete code in your view does a POST as per scriptaculous
default behavior.

What I did in my case was to limit the forgery protection to the
actions in my controller by adding the line

protect_from_forgery :only => [ :create, :update, :destroy ]

Hope this helps.