# Weird mime type set by render\_to\_string (Rails 2.2 / 2.3)

**URL:** <https://www.ruby-forum.com/t/weird-mime-type-set-by-render-to-string-rails-2-2-2-3/159608>\
**Category:** Rails\
**Created:** [February 6, 2009, 10:58am UTC](https://www.ruby-forum.com/t/weird-mime-type-set-by-render-to-string-rails-2-2-2-3/159608 "2009-02-06T10:58:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6de8d8/32.png) [@joost](https://www.ruby-forum.com/u/joost)\
**Post date:** [February 6, 2009, 10:58am UTC](https://www.ruby-forum.com/t/weird-mime-type-set-by-render-to-string-rails-2-2-2-3/159608/1 "2009-02-06T10:58:07Z")

</div>

When using ‘render\_to\_string’ in your views (for some special  
reason 🙂 ) the response.content\_type is set to the wrong value I  
think.

I have a:

respond\_to do |format|  
format.js {}  
end

which in the view uses the render\_to\_string method. The returned  
content type is ‘text/html’ instead of ‘text/javascript’. Now I have  
to fix this using something like:

```
  content_type = response.content_type
  tooltip = render_to_string(:layout => false, :partial => "places/

```

map\_tooltip", :locals =\> {:place =\> place})  
response.content\_type = content\_type

There are lots of tickets on this but I think it still isn’t  
resolved :S

[http://rails.lighthouseapp.com/projects/8994/tickets/1182](http://rails.lighthouseapp.com/projects/8994/tickets/1182)

Any opinions?
