Allow search User through name with whitespaces

This commit is contained in:
taitus
2021-03-25 10:43:53 +01:00
parent 3796ccc874
commit 95503f5811
2 changed files with 12 additions and 1 deletions

View File

@@ -302,7 +302,10 @@ class User < ApplicationRecord
end
def self.search(term)
term.present? ? where("email = ? OR username ILIKE ?", term.strip, "%#{term}%") : none
return none if term.blank?
search = term.strip
where("email = ? OR username ILIKE ?", search, "%#{search}%")
end
def self.username_max_length