Commit 599344583bcf57eff46b36d68e6536188d41c906
1 parent
3faa14e7
Exists in
spb-stable
and in
3 other branches
Remove EmailsObserver
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
8 additions
and
8 deletions
Show diff stats
app/models/email.rb
| ... | ... | @@ -13,14 +13,15 @@ class Email < ActiveRecord::Base |
| 13 | 13 | # Relations |
| 14 | 14 | # |
| 15 | 15 | belongs_to :user |
| 16 | - | |
| 16 | + | |
| 17 | 17 | # |
| 18 | 18 | # Validations |
| 19 | 19 | # |
| 20 | 20 | validates :user_id, presence: true |
| 21 | 21 | validates :email, presence: true, email: { strict_mode: true }, uniqueness: true |
| 22 | 22 | validate :unique_email, if: ->(email) { email.email_changed? } |
| 23 | - | |
| 23 | + | |
| 24 | + after_create :notify | |
| 24 | 25 | before_validation :cleanup_email |
| 25 | 26 | |
| 26 | 27 | def cleanup_email |
| ... | ... | @@ -30,4 +31,8 @@ class Email < ActiveRecord::Base |
| 30 | 31 | def unique_email |
| 31 | 32 | self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email) |
| 32 | 33 | end |
| 33 | -end | |
| 34 | 34 | \ No newline at end of file |
| 35 | + | |
| 36 | + def notify | |
| 37 | + NotificationService.new.new_email(self) | |
| 38 | + end | |
| 39 | +end | ... | ... |