# Turning off the layout in ActionMailer?

**URL:** <https://www.ruby-forum.com/t/turning-off-the-layout-in-actionmailer/163920>\
**Category:** Rails\
**Created:** [March 26, 2009, 5:34am UTC](https://www.ruby-forum.com/t/turning-off-the-layout-in-actionmailer/163920 "2009-03-26T05:34:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [March 26, 2009, 5:34am UTC](https://www.ruby-forum.com/t/turning-off-the-layout-in-actionmailer/163920/1 "2009-03-26T05:34:49Z")

</div>

So I’m happy to see that ActionMailer supports layouts now (it may  
have for a while, but I just now realized it).

But I don’t see a way to turn them off selectively or by multipart  
type.

For example, if I have a layout that’s really simple in “layouts/  
email.html.erb”:

 \<%= yield %\>

I can then use that in my ActionMailer class with a line at the top:  
layout ‘email’

But when I use multipart and have an HTML and a PLAIN file, they both  
use the layout and thus the plain contains the

 tag.

Is there any way to avoid this? or turn it off in certain cases?

Thanks,

-Danimal

---

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [March 26, 2009, 8:27pm UTC](https://www.ruby-forum.com/t/turning-off-the-layout-in-actionmailer/163920/2 "2009-03-26T20:27:32Z")

</div>

Found it: have to monkeypatch but at least it’s simple:  
[http://blog.kreeti.com/rails/multipart-emails-with-mailer-templates](http://blog.kreeti.com/rails/multipart-emails-with-mailer-templates)

Hopefully that’ll soon go in as a bug fix. (and maybe it is for 2.3.  
I’m still on 2.2.2)

-Danimal

P.S. I posted just in case this helps someone else.
