Topic: Autocomplete multiple columns?

I have a person's name stored in two columns: first_name and last_name. I need to autocomplete on both (allow the user to start typing either/both, and show both in the dropdown).

Is this possible?

Re: Autocomplete multiple columns?

i need this too

Re: Autocomplete multiple columns?

use the auto_complete_field Helper, and in the action just do:

def auto_complete
@users = User.find :all, :conditions => [first_name LIKE ? or last_name LIKE ?,params[:search]+"%",params[:search]+"%"]
if !@users.empty?
  render :partial => "autocomplete"
else
  render :nothing
end
end

Model:
class User

def full_name
  self.first_name + " " + self.last_name
end
end


_autocomplete.rhtml:
<ul>
<% @users.each do |user| %>
  <li><%= user.full_name%></li>
<% end %>
</ul>