# Problems with very basic auto\_complete

**URL:** <https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863>\
**Category:** Rails\
**Created:** [August 3, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863 "2008-08-03T14:44:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [August 3, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863/1 "2008-08-03T14:44:51Z")

</div>

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   
tag included

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

thank you very much

---

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [August 3, 2008, 2:54pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863/2 "2008-08-03T14:54:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [August 6, 2008, 9:24pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863/3 "2008-08-06T21:24:32Z")

</div>

come on guys, no help? ☹

---

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [August 7, 2008, 12:45pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863/4 "2008-08-07T12:45:36Z")

</div>

You Need to add a function with name auto\_complete\_for\_general\_title  
in tour controller which will query your database and the results.

---

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [August 7, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/problems-with-very-basic-auto-complete/144863/5 "2008-08-07T13:06:43Z")

</div>

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
