I have created a search box that queries a restaurant database. The
restaurant model is set to search for “name LIKE ?”. However, I
cannot figure out how to add other conditions so that it can also
display “address LIKE ?” and “city LIKE ?”
For example, I want to type in the query “sushi” and find all of the
restaurants that have the name sushi included in them. In this same
box, I would also like to be able to type “oracle rd.” and find all of
the restaurants that have the phrase “oracle rd.” in them.
Essentially, I want to be able to do this in my restaurant model:
def self.search(search)
if search
find(:all, :conditions => [‘name OR address OR city LIKE ?’, “%#
{search}%”])
else
find(:all)
end
end
However, when I do this, it only returns results from the city column.
How can I get my find method to display results for all of these
conditions?