Remove length limits on some user fields #928

This commit is contained in:
Felix Schäfer 2012-03-20 23:42:16 +01:00
parent dafe09ee32
commit e6ec8ab30c
2 changed files with 17 additions and 3 deletions

View File

@ -64,10 +64,9 @@ class User < Principal
validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
# Login must contain lettres, numbers, underscores only
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
validates_length_of :login, :maximum => 30
validates_length_of :firstname, :lastname, :maximum => 30
validates_length_of :login, :firstname, :lastname, :maximum => 255
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
validates_length_of :mail, :maximum => 60, :allow_nil => true
validates_length_of :mail, :maximum => 255, :allow_nil => true
validates_confirmation_of :password, :allow_nil => true
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
validates_inclusion_of :status, :in => [STATUS_ANONYMOUS, STATUS_ACTIVE, STATUS_REGISTERED, STATUS_LOCKED]

View File

@ -0,0 +1,15 @@
class UpUserFieldsLengthLimits < ActiveRecord::Migration
def self.up
change_column :users, :login, :string, :limit => nil
change_column :users, :mail, :string, :limit => nil
change_column :users, :firstname, :string, :limit => nil
change_column :users, :lastname, :string, :limit => nil
end
def self.down
change_column :users, :login, :string, :limit => 30
change_column :users, :mail, :string, :limit => 60
change_column :users, :firstname, :string, :limit => 30
change_column :users, :lastname, :string, :limit => 30
end
end