aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2013-01-25 15:09:31 +1100
committerHenare Degan <henare.degan@gmail.com>2013-01-25 15:09:31 +1100
commita3bc84217bd3b7b8ffc279405629db33edcbe587 (patch)
tree3d57467e5d85b976009a5d1238a9eb9272718eef
parent040ff038e139b8759cdec1a1ad7ece64956a51ec (diff)
ChangeEmailValidator model - Overwriting validate is deprecated in Rails 3
-rw-r--r--app/models/change_email_validator.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb
index 9ef25217d..2ddebb177 100644
--- a/app/models/change_email_validator.rb
+++ b/app/models/change_email_validator.rb
@@ -28,12 +28,15 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable
validates_presence_of :old_email, :message => N_("Please enter your old email address")
validates_presence_of :new_email, :message => N_("Please enter your new email address")
validates_presence_of :password, :message => N_("Please enter your password"), :unless => :changing_email
+ validate :password_and_format_of_email
def changing_email()
self.user_circumstance == 'change_email'
end
- def validate
+ private
+
+ def password_and_format_of_email
if !self.old_email.blank? && !MySociety::Validate.is_valid_email(self.old_email)
errors.add(:old_email, _("Old email doesn't look like a valid address"))
end