# Flush render(:update) buffer to page

**URL:** <https://www.ruby-forum.com/t/flush-render-update-buffer-to-page/86715>\
**Category:** Rails\
**Created:** [February 25, 2007, 12:30am UTC](https://www.ruby-forum.com/t/flush-render-update-buffer-to-page/86715 "2007-02-25T00:30:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabe\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@Gabe\_Lerner](https://www.ruby-forum.com/u/Gabe_Lerner)\
**Post date:** [February 25, 2007, 12:30am UTC](https://www.ruby-forum.com/t/flush-render-update-buffer-to-page/86715/1 "2007-02-25T00:30:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gabe\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@Gabe\_Lerner](https://www.ruby-forum.com/u/Gabe_Lerner)\
**Post date:** [February 25, 2007, 6:54am UTC](https://www.ruby-forum.com/t/flush-render-update-buffer-to-page/86715/2 "2007-02-25T06:54:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gabe\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@Gabe\_Lerner](https://www.ruby-forum.com/u/Gabe_Lerner)\
**Post date:** [February 25, 2007, 10:21am UTC](https://www.ruby-forum.com/t/flush-render-update-buffer-to-page/86715/3 "2007-02-25T10:21:21Z")

</div>

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.
