OpenURI returns two different objects September 24, 2008Posted by John Dewey in Code, Ruby.
StringMax = 10240 def <<(str) @io << str @size += str.length if StringIO === @io && StringMax < @size require 'tempfile' io = Tempfile.new('open-uri') io.binmode Meta.init io, @io if @io.respond_to? :meta io << @io.string @io = io end end
There are several approaches to this problem, but I opted for the easy one. I simply added the following to my model to force a Tempfile.
## # OpenURI::Buffer::StringMax = 10240 OpenURI::Buffer::StringMax = 0