7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/mailers/heya/campaign_mailer.rb', line 7
def build
user = params.fetch(:user)
step = params.fetch(:step)
campaign_name = step.campaign_name.underscore
step_name = step.name.underscore
from = step.params.fetch("from")
bcc = step.params.fetch("bcc", nil)
reply_to = step.params.fetch("reply_to", nil)
subject = step.params.fetch("subject") {
I18n.t("#{campaign_name}.#{step_name}.subject", **attributes_for(user))
}
subject = subject.call(user) if subject.respond_to?(:call)
instance_variable_set(:"@#{user.model_name.element}", user)
instance_variable_set(:@campaign_name, campaign_name)
mail(
from: from,
bcc: bcc,
reply_to: reply_to,
to: to_address(user, step),
subject: subject,
template_path: "heya/campaign_mailer/#{campaign_name}",
template_name: step_name
)
end
|