Trying to use Amy Hoy’s ajaxariffic auto_complete methodology and I am
getting really close to the end.
This is fairly complicated but I will simplify as best I can.
My view code is simple…
<%= text_field_with_auto_complete ‘client’, ‘wholename’ %>
wholename is not a column in ‘clients’ but rather represents an
aggregation of 3 fields…first_name, middle_initial, last_name
my controller code does the necessary part to display the
@clients = Client.find(:all,
:conditions => [“LOWER(first_name||middle_initial||last_name)
‘%’ + params[:client][:wholename].downcase + ‘%’],
:order => ‘last_name ASC’,
:limit => 8)
render :partial => ‘cookies’
and my cookies partial looks like this…
<% for client in @clients do -%>
- <%=h client.clwholename %> <% end -%>
clwholename is the actual aggregation in client.rb
so far so good…when I type a letter or two, the auto_complete list
shows and I can select a name from the list.
But then my problem starts. I can’t easily ‘find’ based on the
aggregate…so I would like it to handle it more like a select list
where the ‘ID’ invisibly accompanies the auto_complete text and thus
selecting an auto_complete item will give me the ID so I don’t have to
then turn around and search for it.
How do I send that with the ‘cookies’ partial?