Forum: Ruby on Rails text_field_with_auto_complete does not obey tokens

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
dankelley (Guest)
on 2007-02-05 01:59
(Received via mailing list)
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
dankelley (Guest)
on 2007-02-05 03:13
(Received via mailing list)
(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.)
Alan F. (Guest)
on 2007-02-05 12:56
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
dankelley (Guest)
on 2007-02-05 14:17
(Received via mailing list)
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.
This topic is locked and can not be replied to.