簡體   English   中英

:link_to中的method =>'delete'似乎在Rails 3中不起作用?

[英]:method => 'delete' in link_to doesn't seem to work in Rails 3?

我正在使用的Rails 3應用程序中有這樣的代碼

    <% @positions.each do |position|  %>
    <tr class="<%= cycle("", "alternate") %>">
        <td><%= position.name %></td>
        <td class="actions">
            <%=link_to 'edit', edit_position_path(position), :class => 'edit' %> |
            <%=link_to 'delete', position_path(position), :confirm => 'Are you sure you want to delete this item?', :method => 'delete' %>
        </td>
    </tr>
    <% end %>

編輯鏈接工作正常,但刪除鏈接不斷帶我到show動作。
知道問題是什么嗎?

PS:我使用formtastic與Mongoid串聯,並且我的config / application.rb文件中沒有加載ActiveRecord。

Rails 3使用不引人注目的javascript來處理刪除,因此您可能需要在布局中添加以下內容:

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

查看railscasts 205以了解如何使用jquery而不是原型。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM