Flush render(:update) buffer to page

Hi,

I would like to have link_to_remote call my action and that action
update the page of its progress using RJS.

In my view, I have:
<%= link_to_remote ‘run lots of code’, :url => { :action =>
‘lots_of_code’ } %>

In my controller, I have:
def lots_of_code
render(:update) do |page|
page.replace_html ‘progress’, ‘test’
end
sleep(3)
@performed_render = false
render(:update) do |page|
page.replace_html ‘progress’, ‘test2’
end
end

Basically, on the page I want to have ‘test’ appear, and then ‘test2’
appear 3 seconds later. I want to somehow flush the response buffer
before the @performed_render line. Is there any way to do this? Or,
is there a better way to accomplish what I want?

Thanks in advance,
Gabe

I actually meant that I wanted to flush the buffer before the sleep(3)
line, as that represents a lot of code being run. Anybody have any
ideas?

Thanks,
Gabe

Gabe Lerner wrote:

I actually meant that I wanted to flush the buffer before the sleep(3)
line, as that represents a lot of code being run. Anybody have any
ideas?

Currently Rails can’t do that, though it’d be easy to make a patch
that allowed you to call “yield” in an action to flush the output.

A hack that may work is:

 $stdout.write response.body
 $stdout.flush
 erase_render_results


We develop, watch us RoR, in numbers too big to ignore.