rails/rails — pull request #10756 by xhoy (2013-05-25 20:54:27+00:00)
Title: Write_fragment give's undefined method errors

DISCLAIMER: This is me first pull request ever, sorry if i did something wrong :)

When you create an object that has no strict representation as a string, the to_str returns an undefined method error.

It was broken in commit https://github.com/rails/rails/commit/a61e3acef25d8fb86275d41a9d0d1ba163d7e0bb

Just added the if respond_to.

This should be fix in (all) supported version of rails imho.

```ruby
>> fragment = {"foo"=>0.0, "bar"=>0.0}
=> {"foo"=>0.0, "bar"=>0.0}
>> fragment_name= "foobar"
=> "foobar"
>> write_fragment(fragment_name, fragment)
!! #0.0, "bar"=>0.0}:Hash>
>>
```