Forum: Ruby on Rails loop action and view

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nanyang Z. (Guest)
on 2007-04-20 01:40
I want to build a loop action, like:
>def loop_action
> @current_job = 0
> 100.each { |i| @current_job = i }
>end

I want the view to display the @current_job information in realtime and
I'd like to have a stop button to stop the loop.

any idea to do this?
Richard L. (Guest)
on 2007-04-20 01:58
(Received via mailing list)
Maybe check out http://juggernaut.rubyforge.org/
 - Richard

On Apr 19, 2:40 pm, Nanyang Z. <removed_email_address@domain.invalid>
alexander (Guest)
on 2007-04-20 02:03
(Received via mailing list)
hi there,
you should look into the ajax/prototype helpers for this kind of
problem.
namely periodically_call_remote which lets your view call a remote
function that returns your @current_job
explained here:
http://api.rubyonrails.org/classes/ActionView/Help...
and remote_function that would let you call a function that would stop
whatever it is that´s incrementing @current_job
explained here:
http://api.rubyonrails.org/classes/ActionView/Help...

cheers
Nanyang Z. (Guest)
on 2007-04-20 02:27
Thank you for replying.
Richard, it's a nice plugin, maybe I'll use it some day. But it seems
too funtionful for my current simple app, and by the way, it needs
flash.

alexander wrote:
> you should look into periodically_call_remote remote_function
both of these function will call an action, how can I request an action
to act on another action?
Nanyang Z. (Guest)
on 2007-04-20 11:23
How about take the action directly into the view?
like
<%
>for job in @jobs%
>#codes to display job and do other things...
>
>end
>%>

if this works, a looooong page will be rendered, (Will it be rendered
when the loop ends or whenever a loop render a display content?)

and still, I have no idea how to stop the loops with a button.
This topic is locked and can not be replied to.