# Text\_field\_with\_auto\_complete

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete/128434>\
**Category:** Rails\
**Created:** [February 7, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434 "2008-02-07T17:43:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [February 7, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434/1 "2008-02-07T17:43:36Z")

</div>

I have the following in my view:

\<% form\_tag :action =\> ‘detail’ do %\>  
Search for Sales Order Number:  
  
\<%= text\_field\_with\_auto\_complete :sales\_order, :id %\>&nbsp;  
\<%= submit\_tag " Go "%\>  
\<% end %\>

And I have the following in my controller:

auto\_complete\_for :sales\_order, :id

This worked fine in 1.5, but now that I’ve upgraded to Rails 2.0.2, and  
installed the auto\_complete plugin, it doesn’t work. The autocomplete  
simply never happens. I can see the stylesheet change, because  
everything on the page gets smaller.

Any ideas on what I’m doing wrong here?

Please let me know if you need more information

Thanks

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [February 7, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434/2 "2008-02-07T18:05:18Z")

</div>

On Feb 7, 2008, at 5:43 PM, Jason F. wrote:

> auto\_complete\_for :sales\_order, :id
> 
> This worked fine in 1.5, but now that I’ve upgraded to Rails 2.0.2,  
> and  
> installed the auto\_complete plugin, it doesn’t work.

Do you have CSRF protection on?

– fxn

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [February 7, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434/3 "2008-02-07T18:11:05Z")

</div>

> Do you have CSRF protection on?

Yes, I did have the protect\_from\_forgery option in the controller. I  
turned it off and now it works. Is there anyway to make this work and  
still have CSRF?

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [February 7, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434/4 "2008-02-07T18:32:34Z")

</div>

On Feb 7, 2008, at 6:11 PM, Jason F. wrote:

> Yes, I did have the protect\_from\_forgery option in the controller. I  
> turned it off and now it works. Is there anyway to make this work and  
> still have CSRF?

You can turn the protection off for Ajax requests  
(skip\_before\_filter :verify\_authenticity\_token) or apply this patch (I  
have not personally tried it yet):

```
http://dev.rubyonrails.org/ticket/10059

```

– fxn

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [February 7, 2008, 7:33pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete/128434/5 "2008-02-07T19:33:28Z")

</div>

> You can turn the protection off for Ajax requests  
> (skip\_before\_filter :verify\_authenticity\_token) or apply this patch (I  
> have not personally tried it yet):
> 
> ```
> http://dev.rubyonrails.org/ticket/10059
> 
> ```

Thank you so much for your help!
