Merge remote-tracking branch 'origin/master' into gs-master

This commit is contained in:
David Yip
2018-03-27 10:44:12 -05:00
18 changed files with 261 additions and 111 deletions

View File

@@ -6,7 +6,7 @@ class UniqueUsernameValidator < ActiveModel::Validator
normalized_username = account.username.downcase.delete('.')
scope = Account.where(domain: nil, username: normalized_username)
scope = Account.where(domain: nil).where('lower(username) = ?', normalized_username)
scope = scope.where.not(id: account.id) if account.persisted?
account.errors.add(:username, :taken) if scope.exists?