Implementing auto complete for more than one field in Rails

Hi,

I have an app, which implements a group feature. Each group has n
members. Also, each group has a group specific profile pic to it.

I have been able to implement auto complete for the group feature
keeping in mind the group name alone. I have referred to the following
tutorial for the same:- http://railsforum.com/viewtopic.php?id=23188

I am using **ruby 1.8.7** and **rails 2.0.2** for project specific
purpose. I have installed the auto_complete plugin in the appropriate
directory. I am on **Ubuntu 10.04** OS

I would like to integrate two more things as part of the current auto
complete feature for groups

1> When I type in a group name in the auto complete text field I should
be able to also see an appropriate group specific profile picture which
show up based on the entered text.

2> I should also be able to see the number of members that would show up
corresponding to each group, based on the entered text in the auto
complete text field.

I am facing the following hurdles going about the same:

Currently the code that I have implemented to get basic auto complete
works based on group name looks like this:-

in **groups_controller.rb**

    auto_complete_for :investor_group, :title

in **index.html.erb** of **groups**

    <%=stylesheet_link_tag "groups"%>
    <%= javascript_include_tag :defaults %>

    Search for a investor group: <%= text_field_with_auto_complete
:investor_group, :title, {}, {:method => :get} %><%=submit_tag
"Search"%>

in **`config/routes.rb`**

    map.resources :investor_group, :collection =>
{:auto_complete_for_investor_groups_title => :get }

I am able to currently display an image for a particular group and
retrieve the total number of members belonging to a group by making use
of the following code in **index.html.erb** of groups:-

    <%for inv_group in @investor_groups%>
    <div class="inv_group_img" align="center"><%=image_tag
"investor_groups/#{inv_group.title}.jpg"%></div>
      <div class="inv_group_details">
    <%=inv_group.activated_members.size%><br>
    <%end%>

The alignment of the view might be hay wire currently, but thats not my
immediate focus. Thus kindly, ignore the same.

I have an idea of what I need to do and I have been able to write some
code for the same in my groups_controller.rb

To get what I require, I tried the following:-

    def calculate_members_count
        @investor_group = InvestorGroup.find(params[:id])
        @members_count = @investor_group.activated_members.size
        return "@members_count", :title
      end

Now this should give me the group title/name and the members_count. I am
not sure how could I fetch the image also within the same method.

Also, from this If it could work correctly, I kinda have done some guess
work for the changes to be reflected in the already written autocomplete
functionality. I am not too sure if they would be correct... but here it
goes..

I changed the following in my **index.html.erb**

    Search for a investor group: <%= text_field_with_auto_complete
:investor_group, :calculate_members_count, {}, {:method => :get}
%><%=submit_tag "Search"%>

I changed the following in my **groups_controller.rb**
auto_complete_for :investor_group,:calculate_members_count

I am really not sure if I am correct till here, if so I really can't
figure out what change I would now need to reflect in **routes.rb**

I wanted to also ask, do I need make some changes to my model by any
chance. I don't think so, but just asked in case.

Also I guess if the auto complete text field supports query search for
only one attribute, in this case would I have to define a customized
auto complete search to suit my requirement? If yes I really have no
idea on how to get a head start, and how to go about it. I may be just
now that there would be also a need of a custom javascript also for
this.

Kindly help me on this. Any inputs on this would be really handy..

Thanks for your patient reading and time..