render_to_string and DoubleRenderError in Rails 4

In Rails 3, render_to_string ensured that the response body was set to nil after rendering so that using it to render something for purposes other than the body and then rendering or redirecting in a controller didn’t raise a DoubleRenderError. In this commit spastorino removed that behavior.

Is there any particular reason why this case isn’t supported anymore? This exactly problem was actually flagged as a bug back in the 3.x days here which is where the “set body to nil” behavior came from originally.

Is this an intentional change? Or is this a bug? I realize there are other issues to deal with now that live/streaming support also intersects with this code. Also, there are other bugs like which are also a result of how render_to_string works (in that case, it’s that the content_type of the response shouldn’t be altered by render_to_string.)

Hey James,

This change was not intentional. Could you open a ticket and mention me and Santiago?


I’ve opened #14693 on GitHub.