# Text\_field\_with\_auto\_complete does not obey tokens

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469>\
**Category:** Rails\
**Created:** [February 5, 2007, 12:59am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469 "2007-02-05T00:59:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dankelley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@dankelley](https://www.ruby-forum.com/u/dankelley)\
**Post date:** [February 5, 2007, 12:59am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469/1 "2007-02-05T00:59:32Z")

</div>

Hi. I’m using the following

\<%= text\_field\_with\_auto\_complete :item, :content, {:skip\_style =\>  
true, :tokens =\> ‘,’} %\>

but it stops auto-completing after I type the first “,” in the field.  
For example, I type “d” and let it complete to “dog”, and then I type  
“,” and another “d”. It doesn’t suggest anything for the second  
token.

I see, from the server output, that it’s sending the following

… WHERE (LOWER(content) LIKE ‘%dog,d%’) …

to mysql. So, it’s not trying to isolate the material after the “,”.

Am I missing something here? For example, do I have to tell my  
controller something in addition to

auto\_complete\_for :item, :content, :limit =\> 20

---

<div class="post-metadata">

**Author:** ![dankelley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@dankelley](https://www.ruby-forum.com/u/dankelley)\
**Post date:** [February 5, 2007, 2:13am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469/2 "2007-02-05T02:13:39Z")

</div>

(I’m answering myself, in case it’s of benefit to someone who searches  
to this thread.)

The problem was that I forgot an element in the hash. It works as  
expected when I write e.g.

\<%= text\_field\_with\_auto\_complete :item, :content, { :size =\> 60},  
{:skip\_style =\> false, :tokens =\> ‘,’} -%\>

(note the :size element … I could have just put {} there also.)

---

<div class="post-metadata">

**Author:** ![dankelley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@dankelley](https://www.ruby-forum.com/u/dankelley)\
**Post date:** [February 5, 2007, 1:17pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469/3 "2007-02-05T13:17:25Z")

</div>

On Feb 5, 6:56 am, Alan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I see you also changed skip\_style from true to false. Was that relevant  
> ?

No, it has no effect except on the aesthetics. I found it looked  
nicer with the new setting.

The key change I made was to add another field, the one with :size in  
it. I could have just put {} for that field, and I would still have  
had working tokenization.

---

<div class="post-metadata">

**Author:** ![dankelley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@dankelley](https://www.ruby-forum.com/u/dankelley)\
**Post date:** [February 5, 2007, 11:56am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-does-not-obey-tokens/84469/4 "2007-02-05T11:56:13Z")

</div>

dankelley wrote:

> (I’m answering myself, in case it’s of benefit to someone who searches  
> to this thread.)
> 
> The problem was that I forgot an element in the hash. It works as  
> expected when I write e.g.
> 
> \<%= text\_field\_with\_auto\_complete :item, :content, { :size =\> 60},  
> {:skip\_style =\> false, :tokens =\> ‘,’} -%\>
> 
> (note the :size element … I could have just put {} there also.)

I see you also changed skip\_style from true to false. Was that relevant  
?

Alan
