# Long Running task percentage indicator in rails

**URL:** <https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955>\
**Category:** Rails\
**Created:** [June 9, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955 "2008-06-09T14:27:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [June 9, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955/1 "2008-06-09T14:27:24Z")

</div>

Hello friends,

I have to create a new project in rails which has a long running task,  
so i need a way to indicate percentage of task completed.

updates like:

0% Task started  
25% task completed  
50% task completed  
75% task completed  
100% complete.  
How can i send these task updates from controller action to view in  
rails.

i find an example in [asp.net](http://asp.net) here  
[http://encosia.com/2007/10/03/easy-incr](http://encosia.com/2007/10/03/easy-incr) … -requests/

how can i do the same thing in ruby on rails.

thanks  
johnny

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [June 9, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955/2 "2008-06-09T14:31:32Z")

</div>

On 9 Jun 2008, at 13:23, Johnny wrote:

> 50% task completed  
> 75% task completed  
> 100% complete.  
> How can i send these task updates from controller action to view in  
> rails.
> 
> i find an example in [asp.net](http://asp.net) here  
> [http://encosia.com/2007/10/03/easy-incr](http://encosia.com/2007/10/03/easy-incr) … -requests/

You can’t follow that approach directly as you can’t send back the  
response bit by bit with rails (and it’s a bad idea to have such long  
running actions because they will stop the mongrel accepting  
connections). The usual approach is to offload the processing task to  
something like backgroundrb.

Fred

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [June 9, 2008, 6:33pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955/3 "2008-06-09T18:33:19Z")

</div>

can i use AJAX updating multiple times within the same controller  
action?  
which method should i use. for getting long running process with last  
around 30 seconds.

On Jun 9, 1:30 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [June 9, 2008, 6:35pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955/4 "2008-06-09T18:35:40Z")

</div>

On 9 Jun 2008, at 17:32, Johnny wrote:

> can i use AJAX updating multiple times within the same controller  
> action?  
> in a nutshell no
> 
> which method should i use. for getting long running process with last  
> around 30 seconds.  
> use backgroundrb, backgroundjob, with feedback via ajax.

Fred

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [June 9, 2008, 11:14pm UTC](https://www.ruby-forum.com/t/long-running-task-percentage-indicator-in-rails/139955/5 "2008-06-09T23:14:34Z")

</div>

> I have to create a new project in rails which has a long running task,  
> so i need a way to indicate percentage of task completed.

see:  
“Rails csv import with progress bar”  
[http://tinyurl.com/6awqjn](http://tinyurl.com/6awqjn)  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/694da7cc25379cbb/220373ebe5e89f35?lnk=gst&q=progress](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/694da7cc25379cbb/220373ebe5e89f35?lnk=gst&q=progress)

Alain
