# Multiple render :text, live

**URL:** <https://www.ruby-forum.com/t/multiple-render-text-live/103094>\
**Category:** Ruby\
**Created:** [May 1, 2007, 8:00pm UTC](https://www.ruby-forum.com/t/multiple-render-text-live/103094 "2007-05-01T20:00:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![knohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@knohr](https://www.ruby-forum.com/u/knohr)\
**Post date:** [May 1, 2007, 8:00pm UTC](https://www.ruby-forum.com/t/multiple-render-text-live/103094/1 "2007-05-01T20:00:35Z")

</div>

I’m new to rails and ruby  
Sorry for the x-post.

I am using “activescaffold” and have a model that takes some time to  
complete, I would like to have it update the page multiple times while  
‘foo’ runs.

basically i have the following

def foo  
render :text =\> “starting”  
…  
end

It displays the text properly, but not untill ‘foo’ has completed.

What I would like to do is something like the following.

def foo  
render :text =\> “starting”  
…  
render :text =\> “#{iteration} / #{total\_iterations}”  
…  
render :text =\> “complete”  
end

---

<div class="post-metadata">

**Author:** ![knohr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@knohr](https://www.ruby-forum.com/u/knohr)\
**Post date:** [May 2, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/multiple-render-text-live/103094/2 "2007-05-02T16:33:30Z")

</div>

On 5/1/07, knohr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m new to rails and ruby  
> Sorry for the x-post.
> 
> I am using “activescaffold” and have a model that takes some time to  
> complete, I would like to have it update the page multiple times while  
> ‘foo’ runs.

You’d be much better asking on the rails google group but:

> basically i have the following
> 
> def foo  
> render :text =\> “starting”  
> …  
> end

I assume that you mean that this is in the controller not the model.

> render :text =\> “complete”  
> end

You’re only allowed one render call per controller action. If you call  
render a second time you’ll get a DoubleRenderError exception.

A controller action processes a single http(s) request, and returns  
one response, this is inherent in the design of the http protocol. If  
you’ve got a copy of Active Web D. with Rails, and if you  
don’t, you should, this is described on page 426 of the second  
edition.

If you want to dynamically update the browser display you need to  
explore techniques like using AJAX to have the browser poll for  
updates.

And that’s DEFINITELY a topic for the rails specific group rather than  
ruby-talk.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
