Class: MyForum::UserMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/my_forum/user_mailer.rb

Instance Method Summary collapse

Instance Method Details

#custom_email(email:, subject:, message:) ⇒ Object



14
15
16
17
# File 'app/mailers/my_forum/user_mailer.rb', line 14

def custom_email(email:, subject:, message:)
  @message = message
  mail(to: email, subject: subject)
end

#ping_from_post(user, topic, page) ⇒ Object



24
25
26
27
28
29
# File 'app/mailers/my_forum/user_mailer.rb', line 24

def ping_from_post(user, topic, page)
  @topic      = topic
  @topic_name = topic.name
  @page       = page
  mail(to: user.email, subject: I18n.t('my_forum.mailer.ping_user', topic_name: @topic_name))
end

#pm_notification(user, sender) ⇒ Object



19
20
21
22
# File 'app/mailers/my_forum/user_mailer.rb', line 19

def pm_notification(user, sender)
  @sender = sender
  mail(to: user.email, subject: I18n.t('my_forum.mailer.new_pm_notification_subject'))
end

#reset_password_email(user) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/mailers/my_forum/user_mailer.rb', line 3

def reset_password_email(user)
  @user = user

  o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
  @new_password = (0...10).map { o[rand(o.length)] }.join

  @user.password = @new_password
  @user.save
  mail(to: @user.email, subject: 'vaz.od.ua - New password')
end