admins can search officials by name or email

This commit is contained in:
Juanjo Bazán
2015-08-29 17:02:21 +02:00
parent c64bb88e12
commit 43b333b844
8 changed files with 19 additions and 11 deletions

View File

@@ -110,8 +110,8 @@ class User < ActiveRecord::Base
update official_position: nil, official_level: 0
end
def self.with_email(e)
e.present? ? where(email: e) : none
def self.search(term)
term.present? ? where("email = ? OR username ILIKE ?", term, "%#{term}%") : none
end
def email_provided?