Skip to content
This repository
Browse code

Adapt [059692a] to make sure we perform correct cloning before manipu…

…lation on `OutputBuffer`.

This has been adapted from [823aa22]. However, after the fragment rendering, `Builder` returns the `String` object instead of `ActionView::OutputBuffer`. Somehow the same procedure which was in [823aa22] does not play nice with the String, and result in the fragment got lost.
  • Loading branch information...
commit 114b5e4b03d27996a2093c789016d6937951eaf6 1 parent bdc80dd
Prem Sichanugrist authored June 08, 2011
8  actionpack/lib/action_view/helpers/cache_helper.rb
@@ -53,7 +53,13 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
53 53
           # This dance is needed because Builder can't use capture
54 54
           pos = output_buffer.length
55 55
           yield
56  
-          fragment = output_buffer.to_str.slice!(pos..-1)
  56
+          if output_buffer.is_a?(ActionView::OutputBuffer)
  57
+            safe_output_buffer = output_buffer.to_str
  58
+            fragment = safe_output_buffer.slice!(pos..-1)
  59
+            self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
  60
+          else
  61
+            fragment = output_buffer.slice!(pos..-1)
  62
+          end
57 63
           controller.write_fragment(name, fragment, options)
58 64
         end
59 65
       end

0 notes on commit 114b5e4

Please sign in to comment.
Something went wrong with that request. Please try again.