Form_remote_for can do :put

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

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

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…

On Jan 23, 2:23 pm, Adam M. [email protected] 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

On 1/23/07, Adam M. [email protected] 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

unknown wrote:

On Jan 23, 2:23 pm, Adam M. [email protected] 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

Ed Hickey wrote:

On 1/23/07, Adam M. [email protected] 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!