Remove EmailsObserver
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
3faa14e7a7
commit
599344583b
2 changed files with 8 additions and 8 deletions
|
@ -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
|
||||
|
||||
def notify
|
||||
NotificationService.new.new_email(self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class EmailObserver < BaseObserver
|
||||
def after_create(email)
|
||||
notification.new_email(email)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue