# Auto Complete

**URL:** <https://www.ruby-forum.com/t/auto-complete/140998>\
**Category:** Rails\
**Created:** [June 20, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/auto-complete/140998 "2008-06-20T17:29:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 20, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/auto-complete/140998/1 "2008-06-20T17:29:20Z")

</div>

Hello All,

The rails auto complete, text\_field\_with\_auto\_complete, compares terms  
using the SQL function LIKE with wildcards on with side of the  
keyword. Although flashy, this is pretty much useless in the greater  
schemesof things. For instance, I have a table with 2500 rows and  
this approach returns the same twenty or so no matter what keywords  
the user enters. Has anyone implemented an autocompletye that  
searches for terms alphabetically?

Regards,

john

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 20, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/auto-complete/140998/2 "2008-06-20T17:35:14Z")

</div>

On Fri, Jun 20, 2008 at 5:28 PM, removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The rails auto complete, text\_field\_with\_auto\_complete, compares terms  
> using the SQL function LIKE with wildcards on with side of the  
> keyword. Although flashy, this is pretty much useless in the greater  
> schemesof things. For instance, I have a table with 2500 rows and  
> this approach returns the same twenty or so no matter what keywords  
> the user enters. Has anyone implemented an autocompletye that  
> searches for terms alphabetically?

You can write your own autocomplete action named

auto\_complete\_for\_#{object}\_#{method}

Compute your custom completions and send back the result with

\<%= auto\_complete\_result @completions %\>

– fxn
