form_remote_tag将不会执行:method => :放

时间:2010-01-08 04:41:21

标签: ruby-on-rails

有人可以告诉我为什么这会执行POST方法而不是我在ajax请求中指定的PUT方法吗?

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

生成输出:

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

2 个答案:

答案 0 :(得分:4)

经过多次愚弄,我发现了这一点。看来我需要把:method =&gt; :把调用放在:html哈希。不知道为什么。如果有人能回答它会有所帮助。

答案 1 :(得分:1)

如果&#34; put&#34;,&#34;删除&#34;或使用其他动词,则会添加名为_method的隐藏输入以模拟帖子上的动词。