fix the validation again

This commit is contained in:
Kyle Drake 2013-06-21 10:48:48 -07:00
parent 4e46043aae
commit 933c354926

View file

@ -74,9 +74,12 @@ class Site < Sequel::Model
# Check for existing user # Check for existing user
user = self.class.select(:username).filter(username: values[:username]).first user = self.class.select(:id, :username).filter(username: values[:username]).first
if !user.nil? || (!new? && user.id != values[:id])
errors.add :username, 'This username is already taken. Try using another one.' if user
if user.id != values[:id]
errors.add :username, 'This username is already taken. Try using another one.'
end
end end
if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH) if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH)