render_to_string が content-type を戻してくんない

render_to_string :update で JavaScript コードを生成してるんだけど、content_type を text/javascript から元に戻してくんないので HTML がそのまま表示されて困った。かなり悩んでた。FirefoxLive HTTP headers エクステンションありがとう!


パッチ作成中。


せっかく作ったけど、パッチあった→。priority が high に設定されてるから、そのうち直るだろ。

Index: actionpack/lib/action_controller/base.rb
===================================================================
--- actionpack/lib/action_controller/base.rb    (revision 5802)
+++ actionpack/lib/action_controller/base.rb    (working copy)
@@ -780,8 +780,10 @@
       # Renders according to the same rules as <tt>render</tt>, but returns the result in a string instead
       # of sending it as the response body to the browser.
       def render_to_string(options = nil, &block) #:doc:
+        content_type = response.content_type
         ActiveSupport::Deprecation.silence { render(options, &block) }
       ensure
+        response.content_type = content_type
         erase_render_results
         forget_variables_added_to_assigns
         reset_variables_added_to_assigns

せっかくだから貼っとこう。