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 https://github.com/rails/rails/commit/c27fde26166f71ec68a7fb501435b656f436a687 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 https://rails.lighthouseapp.com/projects/8994/tickets/5875-render_to_string-json-or-xml-or-update-before-render-results-in-doublerendererror 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 https://github.com/rails/rails/issues/14173 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.)