This project is archived and is in readonly mode.

#1182 ✓resolved
Andreas Gerauer

render_to_string :partial sets response.content_type

Reported by Andreas Gerauer | October 7th, 2008 @ 10:12 AM

Tested on Edge Rails:

The following controller code produces a different content type header on Rails 2.1 and 2.2:


class TestController < ApplicationController
  def index
    render(:json => {:content => render_to_string(:partial => 'test') } )
  end
end

Expected Content Type: application/json

Rails 2.1 Content Type: application/json

Rails 2.2 Content Type: text/html

In Rails 2.1 response.content_type is still nil after render_to_string. In 2.2 render_to_string :partial changes response.content_type to text/html. Because of this the render :json call will not set the content_type correctly.

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages