# Text\_field\_with\_auto\_complete only for the beginning of a string?

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete-only-for-the-beginning-of-a-string/142161>\
**Category:** Rails\
**Created:** [July 3, 2008, 11:07pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-only-for-the-beginning-of-a-string/142161 "2008-07-03T23:07:56Z")\
**Posts on this page:** 2\
**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:** [July 3, 2008, 11:07pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-only-for-the-beginning-of-a-string/142161/1 "2008-07-03T23:07:56Z")

</div>

Hi,

how do I achieve with text\_field\_with\_auto\_complete that writing  
‘ipsum’ in the textbox suggest also ‘lorem ipsum’? so far it works for  
me only whent I know the first letters and type them in. like ‘lo’  
suggests ‘lorem ipsum’ but ‘ip’ suggests nothing.

hopefully it’s pretty easy. thanks a lot

---

<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:** [July 3, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-only-for-the-beginning-of-a-string/142161/2 "2008-07-03T23:15:34Z")

</div>

> Hi,
> 
> how do I achieve with text\_field\_with\_auto\_complete that writing  
> ‘ipsum’ in the textbox suggest also ‘lorem ipsum’? so far it works for  
> me only whent I know the first letters and type them in. like ‘lo’  
> suggests ‘lorem ipsum’ but ‘ip’ suggests nothing.

You need to overwrite the method that does the auto complete searching  
and change it from using a SQL condition “foo%” to “%foo%”. See the  
docs for more info.

-philip
