diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-13 22:03:42 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-13 22:03:42 +0000 |
commit | d21cfe6bb42966f6ae029c434555482dad2aed30 (patch) | |
tree | 06ed00a4c55a3de3500d2a66e4fff96d8ee60dff /app/models | |
parent | ce04c41830d7cc301c7827bfe0c7108815a2bbe6 (diff) | |
download | redmine-d21cfe6bb42966f6ae029c434555482dad2aed30.tar.gz redmine-d21cfe6bb42966f6ae029c434555482dad2aed30.zip |
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10802 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/principal.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb index 90b56b6a1..8e7139c35 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -27,10 +27,10 @@ class Principal < ActiveRecord::Base scope :active, :conditions => "#{Principal.table_name}.status = 1" scope :like, lambda {|q| + q = q.to_s if q.blank? - {} + where({}) else - q = q.to_s pattern = "%#{q}%" sql = "LOWER(login) LIKE LOWER(:p) OR LOWER(firstname) LIKE LOWER(:p) OR LOWER(lastname) LIKE LOWER(:p) OR LOWER(mail) LIKE LOWER(:p)" params = {:p => pattern} @@ -39,7 +39,7 @@ class Principal < ActiveRecord::Base sql << " OR (LOWER(firstname) LIKE LOWER(:a) AND LOWER(lastname) LIKE LOWER(:b)) OR (LOWER(firstname) LIKE LOWER(:b) AND LOWER(lastname) LIKE LOWER(:a))" params.merge!(:a => a, :b => b) end - {:conditions => [sql, params]} + where(sql, params) end } |