Reputation: 2556
I would like to implement a simple search. Let's say the user enters 'york', then I would like to find all records that has a matching substring like 'new york' or 'yorkshire'.
So far I have figured out I will have to use the find method, but I can't figure out how to match for substrings.
Upvotes: 1
Views: 170
Reputation: 1929
You might want to take a look at the Thinking Sphinx plugin for doing such full text search . Solr is also another option .
Upvotes: 0
Reputation: 47542
city = params[:q]
User.find(:all, :conditions=>["city like :text", {:text=>"%#{city}%"} ] )
Upvotes: 4