Forum: Ruby on Rails (nebie) Autocomplete and many to one relationship?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-22 22:56
(Received via mailing list)
All,

I'm trying to get autocomplete to work for the first time.

I'm not sure if I'm doing this right or not.

I have a table where one of the fields is a employees name.  I expect a
relatively small collection of person's names will be used.

I created a simple employees table with just 2 fields: id, and name.

Then in my main table I added a employee_id field and setup the
belongs_to:
/ has_many: entries in the models of each.

In my _form.rhtml I have the autocomplete line that is working:
<%= text_field_with_auto_complete :employee, :name %>

ie. If I start typing, I get a pull-down like entry populated from my
employees table.

The trouble is with the save at the end.  Nothing is getting saved to
either
my employees table in the situation a new employee name is typed, and
not to
my main table.

First, is this supposed to work?

If so, do I have to add code to the update method for my main
controller?
None of the examples I've looked discuss doing so.

Greg
This topic is locked and can not be replied to.