I want to build a loop action, like:>def loop_action > @current_job = 0 > 100.each { |i| @current_job = i } >endI 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe check out http://juggernaut.rubyforge.org/ - Richard On Apr 19, 2:40 pm, Nanyang Zhan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/Helpers/PrototypeHelper.html#M000528 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/Helpers/PrototypeHelper.html#M000534 cheers Nanyang Zhan wrote:>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? > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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_functionboth of these function will call an action, how can I request an action to act on another action? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---