views:

155

answers:

3

I want to render multiple partials in a controller, these will not be part of the response, but pushed to clients via Juggernaut instead.

I'm using render_to_string.

When the second one is called, I get a DoubleRenderError.

How do I render a partial the way that performed? will not be affected?

A: 

Is it not possible to render one view which then renders the two partials in it?

nan
It's of course possible to render a view, which, in turn, renders partials, but it's not possible to render a view, THEN render anything else after that from the controller.
Leventix
A: 

It turns out render_to_string clears off "render results", so you can call it multiple times. The problem was that I called render_to_string in an after_filter hook, after a render was already called.

Leventix
A: 

wait so how can you do this in a after_filter hook? cause im running into the same issue, and have to do an after_filter hook.

btw, im in a similar situation using push tech, but with HTML 5 websockets, and eventmachine

taelor
Try putting it just before the main render call in the controller action, instead of in an after_filter. I've looked into the source code and the render_to_string call manipulates the response, so you shouldn't call this after a render even if you manipulate the `@performed_render` variable.
Leventix
ya, can't really do that. I'm using InheritedResources so after_filters are kinda the way I want to go.
taelor