From 599344583bcf57eff46b36d68e6536188d41c906 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 2 Apr 2014 21:02:02 +0300 Subject: [PATCH] Remove EmailsObserver Signed-off-by: Dmitriy Zaporozhets --- app/models/email.rb | 11 ++++++++--- app/observers/email_observer.rb | 5 ----- 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 app/observers/email_observer.rb diff --git a/app/models/email.rb b/app/models/email.rb index 22e71e4f107..b92c1841063 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -13,14 +13,15 @@ class Email < ActiveRecord::Base # Relations # belongs_to :user - + # # Validations # validates :user_id, presence: true 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 -end \ No newline at end of file + + def notify + NotificationService.new.new_email(self) + end +end diff --git a/app/observers/email_observer.rb b/app/observers/email_observer.rb deleted file mode 100644 index 026ad8b1d9a..00000000000 --- a/app/observers/email_observer.rb +++ /dev/null @@ -1,5 +0,0 @@ -class EmailObserver < BaseObserver - def after_create(email) - notification.new_email(email) - end -end