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'' } %> <span id="progress"></span> 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 On Feb 24, 5:30 pm, "Gabe Lerner" <gabeler...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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'' } %> > <span id="progress"></span> > > 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--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---