Greg Freemyer
2006-May-22 20:54 UTC
[Rails] (nebie) Autocomplete and many to one relationship?
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 -- Greg Freemyer The Norcross Group Forensics for the 21st Century -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060522/4483df47/attachment.html