Using Rails 3.2. I have the following table:
name address
=======================================
Hilton Hotel New York, USA
Hilton Hotel Paris, France
Mandarin Hotel Chicago, USA
Le Meridien Hotel New York, USA
and the following query:
term = "%#{params[:term]}%"
shops = Shop.limit(10).where("name LIKE ? OR address like ?", term, term)
My expected result is this:
Search - "Hilton"
Result - "Hilton Hotel, New York, USA"; "Hilton Hotel, Paris, France"
Search - "Hilton USA"
Result - "Hilton Hotel, New York, USA"
Search - "New York"
Result - "Hilton Hotel, New York, USA"; "Le Meridien Hotel, New York, USA"
How should I rewrite my query?
Thanks.