Skip to content
Browse files

Write strings to fragment cache, not outputbuffers

  • Loading branch information...
1 parent ec760a5 commit eed8a8863d7d5c038b5dd620d4b904ea62528afb @jeremy jeremy committed Mar 11, 2010
View
4 actionpack/lib/action_controller/caching/fragments.rb
@@ -41,7 +41,9 @@ def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
else
pos = buffer.length
block.call
- write_fragment(name, buffer[pos..-1], options)
+ content = buffer[pos..-1]
+ content = content.as_str if content.respond_to?(:as_str)
+ write_fragment(name, content, options)
end
else
block.call
View
10 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -105,15 +105,23 @@ def to_s
self
end
+ def as_str
+ ''.replace(self)
+ end
+
def to_yaml
- "".replace(self).to_yaml
+ as_str.to_yaml
end
end
end
class String
alias_method :add_without_safety, :+
+ def as_str
+ self
+ end
+
def html_safe
ActiveSupport::SafeBuffer.new(self)
end

0 comments on commit eed8a88

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