diff options
author | Semyon Pupkov <semen.pupkov@gmail.com> | 2016-05-23 12:19:27 +0300 |
---|---|---|
committer | Semyon Pupkov <mail@semyonpupkov.com> | 2016-10-23 15:30:07 +0300 |
commit | b1ce2eb1e5f6a4a5b413381489fbb7e63ff3e1e5 (patch) | |
tree | e534764412d32517b1e7e06e86b0516025472311 /app | |
parent | a98ad03ba18da0b1534f36dafafa9a1c644d0bf1 (diff) |
refactor(email): use setter method instead AR callbacks
Diffstat (limited to 'app')
-rw-r--r-- | app/models/email.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/app/models/email.rb b/app/models/email.rb index 32a412ab878..826d4f16edb 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -7,10 +7,8 @@ class Email < ActiveRecord::Base validates :email, presence: true, uniqueness: true, email: true validate :unique_email, if: ->(email) { email.email_changed? } - before_validation :cleanup_email - - def cleanup_email - self.email = self.email.downcase.strip + def email=(value) + write_attribute(:email, value.downcase.strip) end def unique_email |