problems with very basic auto_complete

Guys,

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

#controller
auto_complete_for :general, :title

#view
<% 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 <HEAD>
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 => “off” %>

should be title and not :title

You’ll also need to deal with the forgery protection in rails 2.1 because

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 ‘dangerous’
actions in my controller by adding the line

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

Hope this helps.

Franz