Pass parameters in periodically_call_remote?


#1

Hi,

I am still new to RoR, so please bear with this newbie question. I
would like to have the application in view to press result back to the
controller when the periodically_call_remote is called. Right now,

this is the code in the view:

<%= periodically_call_remote(:update => 'get_result', :url => { :action => "getlog" }, :frequency => 2 ); %>

this is the code in the controller

def getlog
userid = params[:user_id]
if (userid == “1”)
render :text => “Here”
else
render :text => “There”
end
end

I tried periodically_call_remote(:update => ‘get_result’, :url => {
:action => “getlog”, :user_id = “1” }, :frequency => 2 ), but it would
not work


#2

Hi Wai,

Wai T. wrote:

I am still new to RoR, so please bear with
this newbie question.

That’s what we’re here for! :wink: Seriously.

I would like to have the application in view to
press result back to the controller when the
periodically_call_remote is called.

Are you sure? periodically_call_remote is typically used to fetch a
value
from the controller to pass back to the view. It sounds like you’re
wanting
(maybe in the next iteration of your code) to pass a user-entered value
back
to the controller. If that’s the case, then you’ll want to use
observe_field.

To answer the question you asked, though …

:url => { :action => “getlog”, :user_id => ‘1’}

hth,
Bill


#3

Bill W. wrote:

Are you sure? periodically_call_remote is typically used to fetch a
value
from the controller to pass back to the view. It sounds like you’re
wanting
(maybe in the next iteration of your code) to pass a user-entered value
back
to the controller. If that’s the case, then you’ll want to use
observe_field.

To answer the question you asked, though …

:url => { :action => “getlog”, :user_id => ‘1’}

hth,
Bill

Thanks. I will look into observ_field.