OSDN Git Service

Prevent 'has already been taken' error messages for user login and email if these...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 6 Jan 2008 13:09:23 +0000 (13:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 6 Jan 2008 13:09:23 +0000 (13:09 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1042 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb

index 737a8cc..906420e 100644 (file)
@@ -38,7 +38,8 @@ class User < ActiveRecord::Base
   attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
        
   validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
-  validates_uniqueness_of :login, :mail        
+  validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }
+  validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }
   # Login must contain lettres, numbers, underscores only
   validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
   validates_length_of :login, :maximum => 30