# Autocomplete - returning id that has been matched?

**URL:** <https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360>\
**Category:** Rails\
**Created:** [December 6, 2007, 11:03pm UTC](https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360 "2007-12-06T23:03:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 6, 2007, 11:03pm UTC](https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360/1 "2007-12-06T23:03:48Z")

</div>

Hi,

Has anyone got any suggestions or know of any examples where people have  
got an autocomplete field to return the id of the row it has matched on.

I have been attempting to come up with a way to do this with the aim of  
creating a pluign, but every method I have thought of so far seems a  
little over complicated, so I would appreciate any suggestions that  
anyone has

Cheers

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 6, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360/2 "2007-12-06T23:07:27Z")

</div>

On Dec 6, 2007, at 11:03 PM, Scott A S wrote:

> Has anyone got any suggestions or know of any examples where people  
> have  
> got an autocomplete field to return the id of the row it has matched  
> on.
> 
> I have been attempting to come up with a way to do this with the aim  
> of  
> creating a pluign, but every method I have thought of so far seems a  
> little over complicated, so I would appreciate any suggestions that  
> anyone has

Have you tried model\_auto\_completer?

[http://agilewebdevelopment.com/plugins/model\_auto\_completer](http://agilewebdevelopment.com/plugins/model_auto_completer)

– fxn

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 6, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360/3 "2007-12-06T23:09:26Z")

</div>

Scott A S wrote:

> Hi,
> 
> Has anyone got any suggestions or know of any examples where people have  
> got an autocomplete field to return the id of the row it has matched on.
> 
> I have been attempting to come up with a way to do this with the aim of  
> creating a pluign, but every method I have thought of so far seems a  
> little over complicated, so I would appreciate any suggestions that  
> anyone has

The Scaffolding Extensions plugin [1] has a similar autocomplete field.  
It returns the id followed by the name of the object, and you can use  
to\_i to get just the id.

Jeremy

[1]  
[http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin](http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin)

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [December 7, 2007, 8:25am UTC](https://www.ruby-forum.com/t/autocomplete-returning-id-that-has-been-matched/122360/4 "2007-12-07T08:25:47Z")

</div>

Thanks Jeremy and Xavier, that should save me some time!!
