Remove EmailsObserver

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-04-02 21:02:02 +03:00
parent 3faa14e7a7
commit 599344583b
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
2 changed files with 8 additions and 8 deletions

View file

@ -21,6 +21,7 @@ class Email < ActiveRecord::Base
validates :email, presence: true, email: { strict_mode: true }, uniqueness: true
validate :unique_email, if: ->(email) { email.email_changed? }
after_create :notify
before_validation :cleanup_email
def cleanup_email
@ -30,4 +31,8 @@ class Email < ActiveRecord::Base
def unique_email
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end
def notify
NotificationService.new.new_email(self)
end
end

View file

@ -1,5 +0,0 @@
class EmailObserver < BaseObserver
def after_create(email)
notification.new_email(email)
end
end