How to get observe_field to use GET method?

Hi All.

I am trying to set-up observe_field so that it uses the GET method (To
work with a RESTful controller).

<%= link_to_remote(“Test”, :update => “main”, :url => { :controller =>
“projects”, :action => “show”, :id => “3”}, :method => “get” ) %>

<%= observe_field(“project_selector”, :update => “main”, :url => {
:controller => “projects”, :action => “show”}, :with =>
“‘id=’+escape(value)”) %>

I have successfully set-up a link_to_remote so that it works (although I
had to replace the project_path URL with the :controller and :action) as
you can see above however I cannot for the life of me get the
observe_field to work. (Putting :method => ‘get’ into the :url hash
doesn’t work)

Looking at the API there is no html_options specified in the observe
field method so I am wondering if it is possible and I am missing
something or do I need to submit a ticket on edge rails to get all the
prototype helpers updated to allow a :method for RESTful compatibility.

Any help would be much appreciated

Thanks

RJ

I think that :method => ‘get’ is what you want - But it doesn’t need to
go in the :url hash. It should be just like link_to_remote, i.e.
observe_field(“project_selector”, :method => ‘get’, etc…)
The ajax prototype helpers end up calling options_for_ajax which is
clearly looking out for the presence of a method parameter.

Fred

Frederick C. wrote:

I think that :method => ‘get’ is what you want - But it doesn’t need to
go in the :url hash. It should be just like link_to_remote, i.e.
observe_field(“project_selector”, :method => ‘get’, etc…)
The ajax prototype helpers end up calling options_for_ajax which is
clearly looking out for the presence of a method parameter.

Fred

Hoi Fred.

I was afraid that would be the answer :slight_smile: When I do this (and have done
this in the past) the request seems to get screwed up as you can see
from the log below:

Processing ProjectsController#index (for 127.0.0.1 at 2006-11-05
08:16:06) [GET]
Session ID: 2a9b3a8394f406523f33929918b93099
Parameters: {“action”=>“index”, “id”=>“3”, “controller”=>“projects”,
“_”=>nil}

The request is correctly sent as a GET but the action gets changed to
“index” and a “_”=>nil parameter is created for some reason.

Before I started raising tickets I wanted to be sure it is a problem
with edge rather than me just not understanding the helpers. Does anyone
know what is causing this?

Many thanks

RJ

[email protected] wrote:

I’m stuck in the same problem with GET, observer_field and REST
controller with the “_” stuff (some days already :slight_smile:

Have you got any solution or did you raised the ticket?

Priit

I have raised a ticket although the description is slightly different.

I believe the action is going to “index” because the “id” parameter in
:with is not honoured by the restful controller as a proper ID (in that
it doesn’t use the id value specified in the :with hash to construct the
URL which, with a restful get request, means that it goes to the index).

I am still a relative newbie so if you can add some better details it
will probably help

http://dev.rubyonrails.org/ticket/6553

I’m stuck in the same problem with GET, observer_field and REST
controller with the “_” stuff (some days already :slight_smile:

Have you got any solution or did you raised the ticket?

Priit

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs