From 4b6a9136b901ae16ff59b97ff363b3afd82f7413 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 17 Feb 2013 15:16:47 -0500 Subject: [PATCH] fix pool search --- app/helpers/application_helper.rb | 2 +- app/models/pool.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a4587b8c2..5b1fcc8e2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -113,7 +113,7 @@ module ApplicationHelper def search_field(method, options = {}) name = options[:label] || method.titleize - raw '
' + raw '
' end protected diff --git a/app/models/pool.rb b/app/models/pool.rb index cc4d23bbb..2e8c57a19 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -24,19 +24,19 @@ class Pool < ActiveRecord::Base q = scoped return q if params.blank? - if params[:name_matches] - q = q.where("name like ? escape E'\\\\'", params[:name_matches]) + if params[:name_matches].present? + q = q.where("name like ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like) end - if params[:description_matches] - q = q.where("description like ? escape E'\\\\'", params[:description_matches]) + if params[:description_matches].present? + q = q.where("description like ? escape E'\\\\'", params[:description_matches].to_escaped_for_sql_like) end - if params[:creator_name] + if params[:creator_name].present? q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].downcase) end - if params[:creator_id] + if params[:creator_id].present? q = q.where("creator_id = ?", params[:creator_id].to_i) end