I have an action where I do a render_to_string and then a final render
is done to send data back from the action. Here’s the action:
begin File.open(pdfgen.xfdf_file, "w") do |f| f.write(render_to_string(:layout => false)) end pdfgen.generate_pdf rescue return display_popup_error #The 'display_popup_error' does a
render(:text => url_for(:action => 'render_pdf', :filename =>
This works fine. I have another action that is basically the same, but
I get a double render error with that action. The difference between
the two actions is that in the one above, I am certain that the
render_to_string call completes.
In the other action, I am certain that an error occurs during the
render_to_string call, (i.e. the render_to_string call doesn’t
Here’s a hypothesis: A call to render_to_string is marked internally as
one render and then at the end of it, that render count is reduced back
to 0 or cleared somehow. Therefore, a successful call to
render_to_string will allow a later call to render. However, if
render_to_string doesn’t complete, then the render “still counts” and
thus, a double render error if you try to do another render.
Anyone have any insight into the behavior of render_to_string followed
by a render that might explain what I’m seeing?