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.


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




QuirkeyBlog is proudly powered by WordPress