# text\_field\_with\_auto\_complete

**URL:** <https://discuss.rubyonrails.org/t/text-field-with-auto-complete/44153>\
**Category:** rubyonrails-talk\
**Created:** [July 10, 2009, 7:45pm UTC](https://discuss.rubyonrails.org/t/text-field-with-auto-complete/44153 "2009-07-10T19:45:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Walton1](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Bill\_Walton1](https://discuss.rubyonrails.org/u/Bill_Walton1)\
**Post date:** [July 10, 2009, 7:45pm UTC](https://discuss.rubyonrails.org/t/text-field-with-auto-complete/44153/1 "2009-07-10T19:45:47Z")

</div>

Hi Shandy,

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [July 10, 2009, 8:08pm UTC](https://discuss.rubyonrails.org/t/text-field-with-auto-complete/44153/2 "2009-07-10T20:08:42Z")

</div>

bill walton wrote:

> Hi Shandy,
> 
> > I need to pass a parameter in my text\_field\_with\_auto\_complete
> 
> What's the parameter supposed to do? What are you trying to accomplish?
> 
> Bill

Well, I have an auto\_complete to get users names, and in other forms it works great. This auto\_complete, however, it first asks the user to select an account and then pull all the users from that account, so the parameter that I need to pass is the id to the account to populate that list.

---

<div class="post-metadata">

**Author:** ![Bill\_Walton1](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Bill\_Walton1](https://discuss.rubyonrails.org/u/Bill_Walton1)\
**Post date:** [July 10, 2009, 10:14pm UTC](https://discuss.rubyonrails.org/t/text-field-with-auto-complete/44153/3 "2009-07-10T22:14:14Z")

</div>

Ah. Ok. It's been a while since I used auto\_complete and haven't tested this, but it should point you in the right general direction. First though, note that everything after the first two parameters is interpreted as elements of a hash. You don't need the {} notation. The items that can appear in that hash are the parameters to ActiveRecord::Base#find. IIRC auto\_complete just passes them through to the find. You're wanting to supply the :conditions. The syntax may be wrong but I already warned you I haven't tested it. 😉

\<%= text\_field\_with\_auto\_complete 'user', 'username', :conditions =\> ["post = ?", @company\_title.id] %\>

HTH, Bill
