# Question about auto completion field

**URL:** <https://www.ruby-forum.com/t/question-about-auto-completion-field/153786>\
**Category:** Rails\
**Created:** [November 21, 2008, 2:52am UTC](https://www.ruby-forum.com/t/question-about-auto-completion-field/153786 "2008-11-21T02:52:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![on9west](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/6f9a4e/32.png) [@on9west](https://www.ruby-forum.com/u/on9west)\
**Post date:** [November 21, 2008, 2:52am UTC](https://www.ruby-forum.com/t/question-about-auto-completion-field/153786/1 "2008-11-21T02:52:44Z")

</div>

Dear all

I am reading a rails cookbook about the auto\_complete\_for function, the  
code as below

app/controllers/musicians\_controller.rb:

class MusiciansController \< ApplicationController

auto\_complete\_for :musician, :name

def index  
end

def add  
# assemble a band…  
end  
end

app/views/musicians/index.rhtml:

# Musician Selection

\<% form\_tag :action =\> :add do %\>  
\<%= text\_field\_with\_auto\_complete :musician, :name %\>  
\<%= submit\_tag ‘Add’ %\>  
\<% end %\>

My question is that, if the name attribute consists lots of duplicated  
values, how can I distinct them before pass to auto\_complete\_for? I  
afraid the performance would be affected if not to distinct it.

Thank you very much.

Valentino

---

<div class="post-metadata">

**Author:** ![on9west](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/6f9a4e/32.png) [@on9west](https://www.ruby-forum.com/u/on9west)\
**Post date:** [November 21, 2008, 11:50am UTC](https://www.ruby-forum.com/t/question-about-auto-completion-field/153786/2 "2008-11-21T11:50:38Z")

</div>

try this:

[http://wiki.rubyonrails.org/rails/pages/How+to+use+text\_field\_with\_auto\_complete](http://wiki.rubyonrails.org/rails/pages/How+to+use+text_field_with_auto_complete)

On 20 nov, 23:52, Valentino L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
