I’m writing a search function for my application, but I am unsure on how
to search for all results that contain my search string; here’s what
def search @products = Product.find(:all, :conditions => "date_available < now()", :conditions => [ "title ilike ?", @params[:search]], :order => "title desc") end
It works, but only if I provide a full match to the title - how can I do
"title ilike ‘%’?’%’ ?
Also, is this method sql-injection safe ?
Last, but not least - how can I make the search method print output to
the index template ?