Damon Hill
2005-Oct-11 21:42 UTC
Newb: Simple text_field_with_auto_complete question (two fold)
Good day!
I have three tables: products, categories, suppliers.
Model snippets for each:
product.rb
class Supplier < ActiveRecord::Base
has_one :category
has_one :supplier
category.rb
class Category < ActiveRecord::Base
has_many :products
supplier.rb
class Supplier < ActiveRecord::Base
has_many :products
When adding a new product, I obviously want to be able to establish a
supplier/category for the new product.
I would like to do this in a text field w/auto-complete by pulling the
*name* for each supplier/category as well as the id for each
supplier/category.
The name would be displayed to the user in the text field and the id
stored in the database for the given product when saved.
Now, my questions are simple:
1) how do I get the list of names of the suppliers/categories from
inside the product view
2) how do I display the name, but save the id for each of the
suppliers/categories (assuming array here, so should be straight
forward, but are there associative arrays in ruby?)
Thanks in advance for the advice.
Simply pointing to some wiki posting would be sufficient.
M Damon Hill
Project Manager
IFWORLD, Inc.
www.ifworld.com <http://www.ifworld.com/>
"..as we''re sung to sleep by philosophies that sing save the trees
and
kill the children...." -- while you were sleeping (casting crowns)
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails