Autocompete for first_name OR last_name

My autocomplete method searches only on the last_name column but I’d
like for it to search first_name and last_name for a match. Basically
how gmail and yahoo mail beta does it. I tried the sql OR operator but
I can’t get it to work.

def autocomplete
search = params[:user]
@users = User.find(:all,
:conditions => [ ‘LOWER(last_name) LIKE ?’,
‘%’ + search.downcase + ‘%’ ],
:order => ‘last_name ASC’,
:limit => 8) unless search.blank?
render :partial => “search”
end

Thanks for any help!

I don’t see anything wrong with:

@users = User.find(:all,
:conditions => [ ‘LOWER(last_name) LIKE ? OR LOWER(last_name)
LIKE ?’,
“%{search.downcase}%”, “%{search.downcase}%” ],
:order => ‘last_name ASC’,
:limit => 8)

Not able to test right now, mind you.

whoops,
that would be
“%#{search.downcase}%”, “%#{search.downcase}%”
sorry.

I see where I went wrong. Works perfect, thanks!