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

<%= render(:partial, :action=>'myaction') %>
<% periodically_call_remote(:update=>'mydiv', :url=>{:action=>'myaction'}, frequency=>30) %>

but it does not work somehow…

Please help!

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

<%= render(:partial, :action=>'myaction') %>
<% 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

: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.

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

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

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| %>

<%= a.start_time -%> <%= a.message -%> <% end %>

Great. and the controller method ?

A.

Do you have a views/mycontroller/myaction.rhtml file ?

Can you paste the source for ‘myaction’ ?

Alan

Here it is:

<% @alarms.each do |a| %>

<%= a.start_time -%> <%= a.message -%> <% end %>

And here is how it works now, and takes 30 seconds before it appears on
web page:

 
<% periodically_call_remote(:update=>'mydiv', :url=>{:action=>'update_alarms'}, frequency=>30) %>

Alan F. 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| %>

<%= a.start_time -%> <%= a.message -%> <% end %>

Great. and the controller method ?

A.

def update_alarms
@alarms = …
render(:layout -> false)
end

sergey podlesnyi wrote:

And here is how it works now, and takes 30 seconds before it appears on
web page:

 
<% 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…