Class: Decidim::Votings::AccessCodeMailer

Inherits:
ApplicationMailer show all
Includes:
TranslatableAttributes
Defined in:
decidim-elections/app/mailers/decidim/votings/access_code_mailer.rb

Overview

This mailer sends the access code via email.

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#send_access_code(datum, locale = nil) ⇒ Object

Public: Sends an email with the access code.

datum - The datum with the access code locale - The locale that will be used for the email content (optional).

Returns nothing.


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'decidim-elections/app/mailers/decidim/votings/access_code_mailer.rb', line 15

def send_access_code(datum, locale = nil)
  @datum = datum
  @organization = datum.dataset.voting.organization
  @voting = translated_attribute(datum.dataset.voting.title)

  I18n.with_locale(locale || @organization.default_locale) do
    @access_code = datum.access_code

    subject = I18n.t(
      "send_access_code.subject",
      scope: "decidim.events.votings",
      voting: @voting
    )

    mail(to: datum.email, subject: subject)
  end
end