# How to get observe\_field to use GET method?

**URL:** <https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329>\
**Category:** Rails\
**Created:** [November 4, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329 "2006-11-04T18:21:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [November 4, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329/1 "2006-11-04T18:21:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [November 4, 2006, 8:02pm UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329/2 "2006-11-04T20:02:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [November 5, 2006, 9:32am UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329/3 "2006-11-05T09:32:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [November 9, 2006, 12:01pm UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329/4 "2006-11-09T12:01:21Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I’m stuck in the same problem with GET, observer\_field and REST  
> controller with the “\_” stuff (some days already 🙂
> 
> 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](http://dev.rubyonrails.org/ticket/6553)

---

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [November 9, 2006, 8:51am UTC](https://www.ruby-forum.com/t/how-to-get-observe-field-to-use-get-method/74329/5 "2006-11-09T08:51:50Z")

</div>

I’m stuck in the same problem with GET, observer\_field and REST  
controller with the “\_” stuff (some days already 🙂

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

Priit
