Text_field_with_auto_complete does not obey tokens


#1

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


#2

(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.)


#3

On Feb 5, 6:56 am, Alan F. 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.


#4

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