This project is archived and is in readonly mode.

#5814 ✓wontfix
Paul Springett

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

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

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').

Comments and changes to this ticket

  • Aditya Sanghi

    Aditya Sanghi October 16th, 2010 @ 09:18 AM

    • 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 .

  • Aditya Sanghi

    Aditya Sanghi October 16th, 2010 @ 09:49 AM

    ..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)

  • Aditya Sanghi

    Aditya Sanghi October 16th, 2010 @ 08:44 PM

    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?

  • Aditya Sanghi

    Aditya Sanghi October 16th, 2010 @ 08:45 PM

    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

  • Aditya Sanghi

    Aditya Sanghi October 18th, 2010 @ 12:01 PM

    • 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.

  • Jeff Kreeftmeijer

    Jeff Kreeftmeijer November 8th, 2010 @ 08:50 AM

    • Tag cleared.

    Automatic cleanup of spam.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages