ActionMailer: Changing the subject in the template

Here's another little bit to go along with the previous post.

Another thing I didn't quite get/like about some of the ActionMailer setup is that even though you're putting all the email body text in a file somewhere that's not your Mailer class, you put the text of you're subject in there. Some more snooping in the source reveals setting the subject from within the template is easy - your Mailer instance is exposed to the template as 'controller':

<% controller.subject = 'Change of subject' %>
Hello <%= @user.display_name %>

Thank you for your order. 

Love <%= controller.from %>

Comments are closed.

About

QuirkeyBlog is Aaron Quint's perspective on the ongoing adventure of Code, Life, Work and the Web.

twitter/@aq.

instagram/@quirkey.

github/quirkey.

QuirkeyBlog is proudly powered by WordPress

Categories