Class: UserMailer

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

Instance Method Summary collapse

Methods included from WithCertificateRender

#pdf_for, #qr_for

Methods inherited from ApplicationMailer

environment_variables_set?, mailer_environment_variables

Instance Method Details

#certificate(certificate) ⇒ Object



31
32
33
34
35
36
# File 'app/mailers/user_mailer.rb', line 31

def certificate(certificate)
  with_locale certificate.user, certificate.organization do
    attachments[certificate.filename] = pdf_for(certificate)
    mail to: certificate.user.email, subject: t(:certificate_available)
  end
end

#delete_account(user) ⇒ Object



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

def (user)
  with_locale(user) do
    build_email t(:delete_account_mumuki), 'delete_account'
  end
end

#no_submissions_reminder(user) ⇒ Object



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

def no_submissions_reminder(user)
  with_locale(user) do
    build_email t(:start_using_mumuki), 'no_submissions_reminder'
  end
end

#notification(notification) ⇒ Object



38
39
40
41
42
43
44
# File 'app/mailers/user_mailer.rb', line 38

def notification(notification)
  @notification = notification

  with_locale(notification.user, notification.organization) do
    build_email notification.custom_title || t("mailer.title.#{notification.subject}"), 'notification'
  end
end

#we_miss_you_reminder(user, cycles) ⇒ Object



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

def we_miss_you_reminder(user, cycles)
  with_locale(user) do
    build_email t(:we_miss_you), "#{cycles.ordinalize}_reminder"
  end
end

#welcome_email(user, organization) ⇒ Object



6
7
8
9
10
11
# File 'app/mailers/user_mailer.rb', line 6

def welcome_email(user, organization)
  with_locale(user, organization) do
    organization_name = organization.display_name || t(:your_new_organization)
    build_email t(:welcome, name: organization_name), { inline: organization.welcome_email_template }, from: organization.welcome_email_sender
  end
end

#with_locale(user, organization = nil, &block) ⇒ Object



46
47
48
49
50
51
# File 'app/mailers/user_mailer.rb', line 46

def with_locale(user, organization = nil, &block)
  @user = user
  @organization = organization || user.last_organization

  I18n.with_locale(@organization.locale, &block)
end