I tried the example from Rails Cookbook and managed to get it to work. However the text_field_with_auto_complete
works only for one value.
class Expense < ActiveRecord::Base
has_and_belongs_to_many :categories
end
In the New Expense View rhtml
<%= text_field_with_auto_complete :category, :name %>
Auto complete works for the first category. How do I get it working for multiple categories? e.g. Category1, Category2
Intended behavior: like the StackOverflow Tags textbox
Update:
With some help and some more tinkering, I got multiple comma-seperated autocomplete to show up (will post code-sample here).
*However on selection, the last value replaces the content of the text_field_with_auto_complete.* So instead of Category1, Category2.. the textbox shows Category2 when the second Category is selected via auto-complete. Any ideas how to rectify this?