sergey podlesnyi
2006-Apr-19 14:31 UTC
[Rails] Initial load time when periodically_call_remote
When I do periodically_call_remote with e.g. :frequency => 30 after initial page load I have to wait 30 seconds until this partial renders first time. Does anybody know how to make ROR to render partial on web page load, and then start periodic calls every 30 seconds? I tried to put <div id=''mydiv''><%= render(:partial, :action=>''myaction'') %></div> <% periodically_call_remote(:update=>''mydiv'', :url=>{:action=>''myaction''}, frequency=>30) %> but it does not work somehow... Please help! -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Apr-19 14:39 UTC
[Rails] Re: Initial load time when periodically_call_remote
sergey podlesnyi wrote:> When I do periodically_call_remote with e.g. :frequency => 30 > after initial page load I have to wait 30 seconds until this partial > renders first time. Does anybody know how to make ROR to render partial > on web page load, and then start periodic calls every 30 seconds? I > tried to put > > <div id=''mydiv''><%= render(:partial, :action=>''myaction'') %></div> > <% periodically_call_remote(:update=>''mydiv'', > :url=>{:action=>''myaction''}, frequency=>30) %> > > but it does not work somehow... > > Please help!:partial will be looking for a view/_partial, which isn''t wnat you want, as you''re trying to render an action. Does render :action =>''myaction'' work (without the partial) Alan -- Posted via http://www.ruby-forum.com/.
Edward Frederick
2006-Apr-19 14:40 UTC
[Rails] Initial load time when periodically_call_remote
Hi, Yeah, your <%= render(:partial, :action=>''myaction'') %> is broken. If you want to render an entire action, you need to render as a component. However, this is probably not what you should need to do. Look into extracting partials, etc. Ed On 4/19/06, sergey podlesnyi <sergey@zarealye.com> wrote:> When I do periodically_call_remote with e.g. :frequency => 30 > after initial page load I have to wait 30 seconds until this partial > renders first time. Does anybody know how to make ROR to render partial > on web page load, and then start periodic calls every 30 seconds? I > tried to put > > <div id=''mydiv''><%= render(:partial, :action=>''myaction'') %></div> > <% periodically_call_remote(:update=>''mydiv'', > :url=>{:action=>''myaction''}, frequency=>30) %> > > but it does not work somehow... > > Please help! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
sergey podlesnyi
2006-Apr-19 14:41 UTC
[Rails] Re: Initial load time when periodically_call_remote
> > :partial will be looking for a view/_partial, which isn''t wnat you want, > as you''re trying to render an action. Does render :action =>''myaction'' > work (without the partial) > > Alanwill try that.. I guess I tried before but it did not find template, while it finds template for periodic calls. -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Apr-19 15:08 UTC
[Rails] Re: Initial load time when periodically_call_remote
sergey podlesnyi wrote:>> >> :partial will be looking for a view/_partial, which isn''t wnat you want, >> as you''re trying to render an action. Does render :action =>''myaction'' >> work (without the partial) >> >> Alan > > will try that.. I guess I tried before but it did not find template, > while it finds template for periodic calls.Do you have a views/mycontroller/myaction.rhtml file ? Can you paste the source for ''myaction'' ? Alan -- Posted via http://www.ruby-forum.com/.
sergey podlesnyi
2006-Apr-19 15:23 UTC
[Rails] Re: Initial load time when periodically_call_remote
> > Do you have a views/mycontroller/myaction.rhtml file ? > > Can you paste the source for ''myaction'' ? > > AlanHere it is: <% @alarms.each do |a| %> <tr><td><%= a.start_time -%></td> <td><%= a.message -%></td></tr> <% end %> -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Apr-19 15:34 UTC
[Rails] Re: Initial load time when periodically_call_remote
sergey podlesnyi wrote:>> >> Do you have a views/mycontroller/myaction.rhtml file ? >> >> Can you paste the source for ''myaction'' ? >> >> Alan > > Here it is: > > <% @alarms.each do |a| %> > <tr><td><%= a.start_time -%></td> > <td><%= a.message -%></td></tr> > <% end %>Great. and the controller method ? A. -- Posted via http://www.ruby-forum.com/.
sergey podlesnyi
2006-Apr-19 16:08 UTC
[Rails] Re: Initial load time when periodically_call_remote
Alan Francis wrote:> sergey podlesnyi wrote: >>> >>> Do you have a views/mycontroller/myaction.rhtml file ? >>> >>> Can you paste the source for ''myaction'' ? >>> >>> Alan >> >> Here it is: >> >> <% @alarms.each do |a| %> >> <tr><td><%= a.start_time -%></td> >> <td><%= a.message -%></td></tr> >> <% end %> > > Great. and the controller method ? > > A.def update_alarms @alarms = ... render(:layout -> false) end -- Posted via http://www.ruby-forum.com/.
sergey podlesnyi
2006-Apr-19 16:16 UTC
[Rails] Re: Initial load time when periodically_call_remote
And here is how it works now, and takes 30 seconds before it appears on web page: <div id=''mydiv''> </div> <% periodically_call_remote(:update=>''mydiv'', :url=>{:action=>''update_alarms''}, frequency=>30) %> -- Posted via http://www.ruby-forum.com/.
Alex Young
2006-Apr-19 16:25 UTC
[Rails] Re: Initial load time when periodically_call_remote
sergey podlesnyi wrote:> And here is how it works now, and takes 30 seconds before it appears on > web page: > > <div id=''mydiv''> </div> > <% periodically_call_remote(:update=>''mydiv'', > :url=>{:action=>''update_alarms''}, frequency=>30) %>The way I do it is to call a separate function that does the same update call in the window.onload() handler, so there''s basically an extra AJAX call immediately. Not hugely efficient, but it works... -- Alex