# Form\_remote\_for can do :put

**URL:** <https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089>\
**Category:** Rails\
**Created:** [January 23, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089 "2007-01-23T16:37:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 23, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/1 "2007-01-23T16:37:56Z")

</div>

Hello all,

Im tryng to create a remote\_form\_for in a restful app, but cant get the  
method to be put. It appears to default to post if the value is not post  
or get.

is there a trick to this or does form\_for\_remote not have non get/post  
methods.

i tried to add the hidden field forcably but wasnt sure on the syntax. i  
know i need this output.

for the following :method values i get these when inspecting the  
rendered page:

rhtml\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\> Rendered HTML  
:method =\> ‘put’\>\>\>\>\>\>\>\>\>\> method=“post”  
:method =\> ‘sfsdfsdf’\>\>\>\>\> method=“post”  
:method =\> ‘get’\>\>\>\>\>\>\>\>\>\>\> method=“get”

form\_remote\_for usage:

```
<% form_remote_for(
:track,
track,
:url => track_path(track_edit),
:html => { :method => 'put'}) do |f| %>

form stuff here

<%= image_submit_tag 'icons/arrow_refresh' %>

<% end %>
```

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 23, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/2 "2007-01-23T19:24:42Z")

</div>

I’ve just been doing stuff like this:

\<% form\_remote\_for(:track,  
:url =\> track\_path(:id =\> track.id),  
:method =\> “PUT”) do |f| %\>

been working fine for me:-)  
Tim

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 23, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/3 "2007-01-23T23:23:02Z")

</div>

unknown wrote:

> I’ve just been doing stuff like this:
> 
> \<% form\_remote\_for(:track,  
> :url =\> track\_path(:id =\> track.id),  
> :method =\> “PUT”) do |f| %\>
> 
> been working fine for me:-)  
> Tim

hey tim thanks for the reply.

Really? Yours works. Hmmmm.

I was under the impression that the :id assignment was implied through  
order. In this case there is no nesting so i figured track was assigned  
to id.

Im begging to think that the fact that i have the form nested in a row  
of a table, im getting errors there. I checked and there is a list of  
\_method put hidden fields further up…

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 24, 2007, 5:58am UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/4 "2007-01-24T05:58:26Z")

</div>

On Jan 23, 2:23 pm, Adam M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Really? Yours works. Hmmmm.  
> Yep, I’m using that syntax in a good number of places. It does the  
> HTTP PUT and everything works fine.

> I was under the impression that the :id assignment was implied through  
> order. In this case there is no nesting so i figured track was assigned  
> to id.

Sorry I’m not completely following you here, however you definitely  
need to pass the :id to singular\_word\_path() when you want to do a an  
update (e.g. HTTP PUT).

> Im begging to think that the fact that i have the form nested in a row  
> of a table, im getting errors there. I checked and there is a list of  
> \_method put hidden fields further up…

I haven’t tried to do anything with hidden fields in this regaurd but I  
suspect it’s throwing you off track, not really sure.

good luck  
Tim

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 24, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/5 "2007-01-24T17:16:39Z")

</div>

On 1/23/07, Adam M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Tim  
> > I can’t get that to work for me. I 've been using the :html hash for  
> > passing the PUT method as a hidden field. I’ve found this method in the  
> > Beast forum and it seems to work. Though, it does seem like you should  
> > be  
> > able to pass the :method param and have it override POST.

Anyone else have experience with this?

Ed

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [January 24, 2007, 10:28am UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/6 "2007-01-24T10:28:36Z")

</div>

unknown wrote:

> On Jan 23, 2:23 pm, Adam M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Really? Yours works. Hmmmm.  
> > Yep, I’m using that syntax in a good number of places. It does the  
> > HTTP PUT and everything works fine.
> 
> > I was under the impression that the :id assignment was implied through  
> > order. In this case there is no nesting so i figured track was assigned  
> > to id.
> 
> Sorry I’m not completely following you here, however you definitely  
> need to pass the :id to singular\_word\_path() when you want to do a an  
> update (e.g. HTTP PUT).
> 
> > Im begging to think that the fact that i have the form nested in a row  
> > of a table, im getting errors there. I checked and there is a list of  
> > \_method put hidden fields further up…
> 
> I haven’t tried to do anything with hidden fields in this regaurd but I  
> suspect it’s throwing you off track, not really sure.
> 
> good luck  
> Tim

Thanks again for your help.

The hidden fields were added automatically from the form\_remote\_for when  
i specified put as the method.

I have started down a in\_place\_edit path at the moment which is proving  
equally difficult under rest. I will try the remote\_form\_for again.

Adam

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [February 1, 2009, 5:24am UTC](https://www.ruby-forum.com/t/form-remote-for-can-do-put/83089/7 "2009-02-01T05:24:49Z")

</div>

Ed Hickey wrote:

> On 1/23/07, Adam M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > Tim  
> > > I can’t get that to work for me. I 've been using the :html hash for  
> > > passing the PUT method as a hidden field. I’ve found this method in the  
> > > Beast forum and it seems to work. Though, it does seem like you should  
> > > be  
> > > able to pass the :method param and have it override POST.
> 
> Anyone else have experience with this?
> 
> Ed

I was having a similar problem and in the end it was because  
prototype.js wasn’t loading and it was sending the form request as GET  
instead of POST (or pseudo PUT depends on how you want to think about  
it)

in my .htaccess I added this rule

RewriteCond %{REQUEST\_URI} ^/javascripts.\*  
RewriteRule .\* - [L]

Which allowed prototype.js to load and it worked.

Hope this helps someone!
