Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

render :template sends malformed Content-Type header for ActionMailer views

#5814

Given the following controller action

def show_email_in_browser
    render :template => "my_mailer/email_template.text.html.erb", :layout => false
end

I see the following HTTP response headers

Date: Fri, 15 Oct 2010 10:01:26 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.2 Phusion_Passenger/2.2.15
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
Etag: "11e7ec03cd2aa06d9a0b6e01f401b121"
X-Runtime: 482
Cache-Control: private, max-age=0, must-revalidate
Content-Length: 4003
Status: 200
Content-Type: text.html; charset=utf-8

Note the Content-Type is "text.html" not "text/html"

This in known to affect Safari 5.0.x (Mac) -- causing the browser to treat the response as an attachment to download (in this example the file would be named 'show_email_in_browser').

Reported by Paul Springett · October 15th, 2010 @ 11:11 AM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Aditya Sanghi
    Aditya Sanghi
    • State changed from new to needs-more-info
    • Importance changed from to Low

    Paul, Can you confirm if this problem goes away if you rename the template to email_template.html.erb?

    Mailer template name should be email_template.text.erb or email_template.html.erb not email_template.text.html.erb.

    I'll investigate further how the content-type is being worked out in case the name is wrongly provided as email_template.text.html.erb .

    October 16th, 2010 @ 09:18 AM

  2. Aditya Sanghi
    Aditya Sanghi

    ..just confirming that this is not a problem on Rails 3.0 (even if you name your template email_template.text.html.erb). (I only realized right now that you were on 2.3.9)

    October 16th, 2010 @ 09:49 AM

  3. Aditya Sanghi
    Aditya Sanghi

    I also now confirm that this problem exists on 2.3.x. Paul can you submit a failing test and/or a patch to solve the problem?

    October 16th, 2010 @ 08:44 PM

  4. Aditya Sanghi
    Aditya Sanghi

    Sorry to post right back, but i also confirm that this problem is NOT there if the template is named correctly as email_template.html.erb or email_template.text.erb

    October 16th, 2010 @ 08:45 PM

  5. Aditya Sanghi
    Aditya Sanghi
    • State changed from needs-more-info to wontfix

    Okay i've investigated this deeper, and there has been major refactoring in Rails 3 around this area of rendering where this is not a problem.

    Also I have already mentioned that the right way to solve your problem is to rename your template correctly, which is also the documented way of naming your template in Rails 2/3.x

    Marking ticket as wontfix. Please feel free to comment if you think otherwise but it is unlikely that this will be fixed in the 2.3.x branch unless you can provide a patch with tests and it is accepted by the core committers.

    October 18th, 2010 @ 12:01 PM

  6. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.

    Automatic cleanup of spam.

    November 8th, 2010 @ 08:50 AM