On May 10, 2011, at 7:23 PM, Mlle wrote:

Hi

Is it possible to use the autocomplete plugin to search using a
keyword on more than one field of a model?  How can I do that?

When you use autocompletion, you define a field to watch, and an endpoint to query against. Whatever query conditions you put in the method that "answers" that endpoint will be the results that appear in the autocompleter's list.

So if you had generated:

new Ajax.Autocompleter('person','/people/lookup',{});

Then in Person#lookup you would be looking for

Person.all(:conditions => ['first_name LIKE ? OR last_name LIKE ?'],"#{params[:value]}%","#{params[:value]}%"])

Crude example, but you get the idea...

Walter


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en .


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to