This project is archived and is in readonly mode.

#1478 ✓resolved
Brady Bouchard

Override content type when rendering default error file

Reported by Brady Bouchard | November 26th, 2008 @ 08:35 AM | in 2.x

If a template is rendered with a content type other than 'text/html', when an exception is raised and considered a non-local request, the default error file (500.html) will be rendered with the specified content type rather than 'text/html'. This can cause wonkiness in some browsers.

For example:

class DummyController < ApplicationController
  def index
    render :inline => "<%= response.bad_method %>", :content_type => 'text/plain'

When the above method is accessed, the default file (500.html) will be rendered with a content type of 'text/plain', which will cause browsers such as Safari to render the page as plain text rather than HTML. Ugly.

A fix is attached. I spent quite a bit of time trying to come up with a test, but it looks like a test would mean adding quite a bit of code to either rescue_test.rb or render_test.rb (since it requires both the set up code for rendering as well as rescuing). If anyone can code one up, that would be great - and/or point me in the right direction.

Comments and changes to this ticket

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=""></a>

People watching this ticket


Referenced by