Forum: Ruby on Rails Pass parameters in periodically_call_remote?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wai T. (Guest)
on 2007-02-06 23:07
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:

<div id="get_result"></div>
<%= 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
Bill W. (Guest)
on 2007-02-07 00:38
(Received via mailing list)
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! ;-)  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
Wai T. (Guest)
on 2007-02-07 22:29
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.
This topic is locked and can not be replied to.