This post originated from an RSS feed registered with Ruby Buzz
by rwdaigle.
Original Post: What's New in Edge Rails: Mailer Layouts
Feed Title: Ryan's Scraps
Feed URL: http://feeds.feedburner.com/RyansScraps
Feed Description: Ryan Daigle's various technically inclined rants along w/ the "What's new in Edge Rails" series.
Rails mailer templates now have the ability to utilize layouts just like their view-template siblings. The only caveat is that for a mailer layout to be automatically recognized it must end with _mailer. So this mailer:
123456
classUserMailer < ActionMailer::Basedefregistration(user) subject "You've registered" from "system@example.com"endend
would need a layout at layouts/user_mailer.html.erb. If you explicitly specify the layout it doesn’t need the _mailer suffix. So, in this example, a layout at layouts/email.html.erb would suffice: