# Autocomplete text field with HABTM association - PLEASE HELP

**URL:** <https://www.ruby-forum.com/t/autocomplete-text-field-with-habtm-association-please-help/193774>\
**Category:** Rails\
**Created:** [August 24, 2010, 6:42am UTC](https://www.ruby-forum.com/t/autocomplete-text-field-with-habtm-association-please-help/193774 "2010-08-24T06:42:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![agilehack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d2c977/32.png) [@agilehack](https://www.ruby-forum.com/u/agilehack)\
**Post date:** [August 24, 2010, 6:42am UTC](https://www.ruby-forum.com/t/autocomplete-text-field-with-habtm-association-please-help/193774/1 "2010-08-24T06:42:03Z")

</div>

can anyone help me work this functionality out? I actually have 3  
classes each with a HABTM relationships with each other but right now  
I am just trying to get one to work. I have 2 models, ‘employees’ and  
‘practices’ (healthcare field), and would like to have a text field on  
the ‘employees’ new and edit views so the practice(s) this employee  
belongs to can be added.

I have the linking table employees\_practices created successfully and  
the HABTM associations created in the models (to each other).  
I have installed the plugin: script/plugin install  
git://github.com/rails/auto\_complete.git

- as it is no longer included in rails 2.3.8.  
I have included the \<%= javascript\_include\_tag :defaults %\> in the  
application.html.erb ((so its available throughout the app))  
I have included \<%= text\_field\_with\_auto\_complete :practice, :name  
%\> in my \_form for ‘employees’  
I have added auto\_complete\_for :practice, :name to my employee  
controller

i normally get some variety of ‘method undefined…etc’ or some other  
variation no matter what i do.  
couple things: I did not create a new search controller as I am  
trying to add this text field to the existing views for ‘employee’  
generated when I used nifty\_scaffold to create employee. Also I feel  
like at least some of my issue is definitely in the controller, I  
don’t think just adding auto\_complete\_for :practice, :name to the  
controller should work. I have tried all sorts of methods and can’t  
get it to work.  
I would like to actually be able to list multiple ‘practices’ in the  
field separated by commas (something about using a token?

can anyone walk me through this? help with the controller? everything  
else look right?

Thanks
