Commit 59934458 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove EmailsObserver

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 3faa14e7
...@@ -13,14 +13,15 @@ class Email < ActiveRecord::Base ...@@ -13,14 +13,15 @@ class Email < ActiveRecord::Base
# Relations # Relations
# #
belongs_to :user belongs_to :user
# #
# Validations # Validations
# #
validates :user_id, presence: true validates :user_id, presence: true
validates :email, presence: true, email: { strict_mode: true }, uniqueness: true validates :email, presence: true, email: { strict_mode: true }, uniqueness: true
validate :unique_email, if: ->(email) { email.email_changed? } validate :unique_email, if: ->(email) { email.email_changed? }
after_create :notify
before_validation :cleanup_email before_validation :cleanup_email
def cleanup_email def cleanup_email
...@@ -30,4 +31,8 @@ class Email < ActiveRecord::Base ...@@ -30,4 +31,8 @@ class Email < ActiveRecord::Base
def unique_email def unique_email
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email) self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end end
end
\ No newline at end of file def notify
NotificationService.new.new_email(self)
end
end
class EmailObserver < BaseObserver
def after_create(email)
notification.new_email(email)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment