From cc96c60c4617c09379d5e1ddbefa42407329c19a Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 18 Jul 2013 12:12:07 +0200 Subject: testing all versions of emial identities, emails are now strings --- users/app/models/email.rb | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'users/app/models/email.rb') diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 6d82f2a..90fc645 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -1,6 +1,5 @@ -module Email - extend ActiveSupport::Concern - +class Email < String +=begin included do validates :email, :format => { @@ -8,26 +7,14 @@ module Email :message => "needs to be a valid email address" } end - - def initialize(attributes = nil, &block) - attributes = {:email => attributes} if attributes.is_a? String - super(attributes, &block) - end - - def to_s - email - end - - def ==(other) - other.is_a?(Email) ? self.email == other.email : self.email == other - end +=end def to_partial_path "emails/email" end def to_param - email + to_s end end -- cgit v1.2.3 From d96fac2de074bbe3a44d888af5ceaff45b1b9b27 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 18 Jul 2013 12:52:02 +0200 Subject: validations of email format and local domain moved over --- users/app/models/email.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'users/app/models/email.rb') diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 90fc645..1bcff1c 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -1,13 +1,11 @@ class Email < String -=begin - included do - validates :email, - :format => { - :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, - :message => "needs to be a valid email address" - } - end -=end + include ActiveModel::Validations + + validates :email, + :format => { + :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, + :message => "needs to be a valid email address" + } def to_partial_path "emails/email" @@ -17,4 +15,8 @@ class Email < String to_s end + def email + self + end + end -- cgit v1.2.3