Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

form_remote_tag won't execute :method => :put

Tags:

Can someone tell me why this is executing the POST method instead of my PUT method that I specify on the ajax request?

<% form_remote_tag(
    :url => contact_url(detail),
    :method => :put,
    :complete => "Element.toggle($('#{form_id}))",
    :success => visual_effect(:shake, "contact-#{detail.id}"),
    :update => "contact-#{detail.id}",
    :html => {:id => form_id, :style => "display:none"}) do %>

Generated output:

<form action="/contacts/1" id="tag-form-for-1" method="post" onsubmit="new Ajax.Updater('contact-1', '/contacts/1', {asynchronous:true, evalScripts:true, method:'put', onComplete:function(request){Element.toggle($('tag-form-for-1))}, onSuccess:function(request){new Effect.Shake(&quot;contact-1&quot;,{});}, parameters:Form.serialize(this)}); return false;" style="display:none">


<div style="margin:0;padding:0;display:inline">
<input name="authenticity_token" type="hidden" value="7807qAkHN3c1yyZlLoy9Z5pUByviR5az9vtuHHBbVv4=" />
</div>

<input id="tag_list" name="tag_list" size="40" type="text" value="Home Pittsburgh Ginger" />
<input id="form_id" name="form_id" type="hidden" value="tag-form-for-1" />

</form>
like image 447
Adam T Avatar asked Jan 08 '10 04:01

Adam T


2 Answers

After much fooling around I figured this out. It appears I need to put the :method => :put call in the :html hash. Not sure why. If someone could answer that it would be helpful.

like image 145
Adam T Avatar answered Oct 11 '22 11:10

Adam T


If "put", "delete", or another verb is used, a hidden input with name _method is added to simulate the verb over post.

like image 30
Loi Cao Avatar answered Oct 11 '22 09:10

Loi Cao