From: Matthieu Stone Date: 2007-04-01T04:43:45+09:00 Subject: Re: updating an RJS template _while_ executing a method Here's one way In your method doing the IO stuff, update a session variable with the message that you want displayed; ie: def my_io_process session[:message] = "Starting..." do something session[:message] = "Updated message" do something else.. etc session[:message] = nil end Create another controller method that just returns the value of session[:message]. def update_message render :text => session[:message]; :layout => false end So now, all you need is a periodic routine that updates a div on the page with the session[:message] contents. You can either update the div directly from this call, or like I do, use RJS to do other things on the page. This polling is turned on & off by the javascript variable poll_message <%= periodically_call_remote( :condition => "poll_message == true", :frequency => 2, :url => { :action => 'update_message', :only_path => false } ) %> You can turn poll_message on & off like this, just include this code in a RJS update whenever you want to change turn the polling on & off. Rgds, - matt. -----Original Message----- From: ruby-talk@hinv.org [mailto:ruby-talk@hinv.org] Sent: 31 March 2007 17:56 To: ruby-talk ML Subject: updating an RJS template _while_ executing a method I have a method doing I/O stuff which takes quite a long time. While this method is processed, I want the user of my tool to be informed of the current execution state. For example, if the method opens a file, I want my RJS template to render a message such as "opening file XYZ...", if the method changes to a directory, message would be "cd to ...". As far as I can tell, RJS templates are rendered AFTER the corresponding method is executed. But I want them to run (sort of) synchronously. Or at least have a way to trigger messages while a method is executed. Cheers, Tom.