Forum: Ruby on Rails ActionMailer Layout on HTML version not Plain Text

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2ebf42f8625b86c0e91ae7bd4e2bef52?d=identicon&s=25 Raymond O'Connor (nappin)
on 2009-03-06 01:55
I'm sending plain text and html emails by having multiple files for each
email I send.  For example, for my registration email I have a
registration.text.plain.erb file and a registration.text.html.erb file.
I want to use a layout for the html version of my emails.  In my mailer
I put:

class AccountsMailer < ActionMailer::Base
  layout 'email'

Unfortunately rails seems to look for views/layouts/email.html.erb and
uses that layout for both my HTML and plain text emails.  When I name
the file email.text.html.erb rails complains:

Missing layout layouts/email.erb ...

How do I set up action mailer so that it uses a layout only for the html
version of emails?

2ebf42f8625b86c0e91ae7bd4e2bef52?d=identicon&s=25 Raymond O'Connor (nappin)
on 2009-03-10 12:25
Is there really no way to do this?  This pretty much makes actionmailer
layouts useless if you are sending html emails with plain text
9f9c3cd0120e224edb912be6e706f125?d=identicon&s=25 Iain Adams (Guest)
on 2009-03-17 10:54
(Received via mailing list)
Did you ever find an answer to this? I have the exact same problem.

claims you can use different content types (plain/html) but it doesn't
work for me

On Mar 10, 11:25 am, Raymond O'Connor <rails-mailing-l...@andreas-
E00fa5dff361e0bed4b488d874960889?d=identicon&s=25 Danimal (Guest)
on 2009-03-26 05:54
(Received via mailing list)

I just posted the exact same issue here before I saw this thread. It
doesn't work for me on Rails 2.2.2.

I was really excited to see layouts in ActionMailer, but this is
frustrating. *sigh*


(I'm poking around in the ActionMailer code to see if there is
anything I can find)
E00fa5dff361e0bed4b488d874960889?d=identicon&s=25 Danimal (Guest)
on 2009-03-26 06:02
(Received via mailing list)
BTW, looks like this has been a known bug for a little while:

(since January at least).


Hopefully someone will fix it. If I knew the internals of Rails
better, I'd give it a go myself.

E00fa5dff361e0bed4b488d874960889?d=identicon&s=25 Danimal (Guest)
on 2009-03-26 20:21
(Received via mailing list)
Woo hoo! Fix discovered!

Whew! I wasted 4 hours last night trying to monkeypatch ActionMailer
but I was futzing around in the wrong places.

I added Surendra's suggestion as a monkeypatch and it works great!

Ok, on to other stuff...

This topic is locked and can not be replied to.