This project is archived and is in readonly mode.
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
-
vibha October 24th, 2008 @ 11:44 AM
- Tag changed from 2.2, actionpack, content_type, partial, render_to_string to 2.2, actionpack, content_type, partial, render_to_string
working on Rails 2.1.0, i did same
and got response.content_type as "application/json" for Rails 2.1
-
DHH October 30th, 2008 @ 11:19 AM
- Milestone cleared.
- Assigned user set to josh
-
Repository October 30th, 2008 @ 08:26 PM
- State changed from new to resolved
(from [2092687bcb35a3d30e1d05d3f5f461d8f4e8f9b7]) Ensure content type gets reset after render_to_string [#1182 state:resolved] http://github.com/rails/rails/co...
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>
People watching this ticket
Referenced by
- 1182 render_to_string :partial sets response.content_type (from [2092687bcb35a3d30e1d05d3f5f461d8f4e8f9b7]) Ensure ...
- 1503 Wrong mime type in rjs response in Rails 2.2.2 (sometimes) Take a look at #870 or #1182, they sound related.