0
我在使用複選框刪除多個konkurrancers時遇到問題。 我提交我的表單時出現此錯誤鑑於:Rails有助於刪除多個
Routing Error
No route matches "/admin/konkurrancers/delete_multiple"
我index.erb.html:
<h1>Alle konkurrencer</h1>
<div id="konkurrancer"><%= render 'konkurrencer', :remote => true %></div>
<%= link_to 'Opret konkurrence', new_admin_konkurrancer_path, :class => 'link' %>
<%= link_to 'Tilbage', :admin, :class => 'admina' %>
我_konkurrencer部分:
<% form_tag delete_multiple_admin_konkurrancers_path do %>
<div id="tabel">
<table id="tabel1" border="0" bordercolor="#000000" style="background-color:#FFFFFF" width="950" cellpadding="0" cellspacing="0">
<tr id="toptr">
<td> </td>
<td ><%= sortable "name", "Navn" %></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<% for konkurrancer in @konkurrancers %>
<tr class="thumbnail-item" onmouseout="this.style.background='white';" onmouseover="this.style.background='#99ff33';this.style.cursor='pointer'">
<td><%= check_box_tag "konkurrancer_ids[]", konkurrancer.id %></td>
<td> </td>
<td><%= link_to 'Vis', admin_konkurrancer_path(konkurrancer.id) %></td>
<td><%= link_to 'Redigere', {:action => 'edit', :id => konkurrancer.id}, :class => 'action edit' %></td>
<td><%= link_to 'Slet', admin_konkurrancer_path(konkurrancer.id), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<div id="pagenavi">
<%= submit_tag "Delete Checked" %>
<% end %>
<%= hidden_field_tag :direction, params[:direction] %>
<%= hidden_field_tag :sort, params[:sort] %>
</div>
我的管理員/ konkurrancers控制器:
def delete_multiple
@konkurrancer = Konkurrancer.find(params[:konkurrancer_ids])
@konkurrancer.each do |konkurrancer|
konkurrancer.destroy
end
end
我的路線:
delete_multiple_admin_konkurrancers DELETE /admin/konkurrancers/delete_multiple(
.:format) {:action=>"delete_multiple", :controller=>"admin/konkurrancers"}
admin_konkurrancers GET /admin/konkurrancers(.:format)
{:action=>"index", :controller=>"admin/konkurrancers"}
POST /admin/konkurrancers(.:format)
{:action=>"create", :controller=>"admin/konkurrancers"}
new_admin_konkurrancer GET /admin/konkurrancers/new(.:format)
{:action=>"new", :controller=>"admin/konkurrancers"}
edit_admin_konkurrancer GET /admin/konkurrancers/:id/edit(.:forma
t) {:action=>"edit", :controller=>"admin/konkurrancers"}
admin_konkurrancer GET /admin/konkurrancers/:id(.:format)
{:action=>"show", :controller=>"admin/konkurrancers"}
PUT /admin/konkurrancers/:id(.:format)
{:action=>"update", :controller=>"admin/konkurrancers"}
DELETE /admin/konkurrancers/:id(.:format)
{:action=>"destroy", :controller=>"admin/konkurrancers"}
我的routes.rb
命名空間:管理員做 資源:konkurrancers做 集合所做 刪除:delete_multiple 結束 結束 結束
現在我得到提交此錯誤:路由錯誤 沒有路由匹配「/管理/ konkurrancers/delete_multiple」 – 2011-04-02 12:27:38
對不起,那是因爲你可能POST'ng它,這是默認的。 – brad 2011-04-02 12:40:29
如何將其更改爲刪除? – 2011-04-02 12:42:02