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("contact-1",{});}, 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>
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.
If "put", "delete", or another verb is used, a hidden input with name _method is added to simulate the verb over post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With