Answer the question
In order to leave comments, you need to log in
How to display data from a variable in the subject and body of the letter?
It is necessary to display data from a variable in a certain place in the text of the letter. The texts of the letters are stored in the database. Added @tmp variable in Mailer controller. In the text of the letter I add <%= @tmp %>, but it doesn't work, it displays - <%= @tmp %>. Tried #{@tmp}, same result.
Answer the question
In order to leave comments, you need to log in
Where a letter template from the database is substituted into the body of the letter, you need to use the ERB processor, while passing the current context (binding) into it
@tmp = 'Some value'
email_body = ERB.new(mail_template_from_database).result(binding)
mail(to: user_email, body: email_body, content_type: "text/html", subject: "Email subject")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question