Skip to content

Instantly share code, notes, and snippets.

@wallace
Created May 12, 2009 03:48
Show Gist options
  • Save wallace/110297 to your computer and use it in GitHub Desktop.
Save wallace/110297 to your computer and use it in GitHub Desktop.
diff --git a/app/models/user.rb b/app/models/user.rb
index 36ac8a2..dba8fcb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -69,10 +69,14 @@ class User < ActiveRecord::Base
validate_code_nil_or_unique
# if password confirmation is set, make sure it matches password
- if !self.password_confirmation.blank? and self.password != self.password_confirmation
+ if (not self.password.blank? or not self.password_confirmation.blank?) and self.password != self.password_confirmation
errors.add('password', 'confirmation does not match')
end
-
+
+ if self.password.blank? and self.password_confirmation.blank?
+ errors.add('password', 'can not be blank')
+ end
+
# account owners can not have blank emails
errors.add('email', 'can not be blank') if self.is_account_owner? and self.email.blank?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment