我的销毁链接不起作用。
我的索引视图:

<div id="konkurrancer"><%= render 'konkurrencer', :remote => true %></div><%= debug(params) %>

我的魔术师部分:
<% for konkurrancer in @konkurrancers %>    <%= link_to 'Destroy', [:admin, konkurrancer], :method => :delete %> <% end %>

我得到这个错误:
No route matches {:action=>"show", :controller=>"admin/konkurrancers", :id=>#<Konkurrancer id: 41, name: " Vind 16.000 kr., til Bilka, Føtex eller Netto

视图中的编辑错误:
ActionController::RoutingError in Admin/konkurrancers#index

Showing C:/Rails/konkurranceportalen/app/views/admin/konkurrancers/_konkurrencer.html.erb where line #59 raised:

No route matches {:action=>"show", :controller=>"admin/konkurrancers", :id=>#<Konkurrancer id: 41, name: " Vind 16.000 kr., til Bilka, Føtex eller Netto", banner1: "http://partner.smartresponse-media.com/42/1092/1210...", banner2: "http://partner.smartresponse-media.com/42/1092/1210...", vaerdi: 16000, note: "", udtraekkes: "2011-05-31 22:00:00", created_at: "2011-05-04 12:35:44", updated_at: "2011-05-05 14:55:35", cached_slug: "vind-16000-kr-til-bilka-f\xC3\xB8tex-eller-netto", tid: "4 min", form: "Quiz", rating_score: 5, ratings: 1, rating: 5, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, photo2_file_name: nil, photo2_content_type: nil, photo2_file_size: nil, photo2_updated_at: nil, image_remote_url: "", image_remote_url_2: "">}

Extracted source (around line #59):

56:       <td><%= konkurrancer.form %></td>
57:        <td><%= link_to 'Vis', admin_konkurrancer_path(konkurrancer.id) %></td>
58:     <td><%= link_to 'Redigere', {:action => 'edit', :id => konkurrancer.id}, :class => 'action edit' %></td>
59:     <td> <%= link_to 'Destroy', admin_konkurrancer_path(konkurrancer), :method => :delete %> </td>
60:
61:
62:     </td>

耙路:
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"}

我的路由文件:
namespace :admin do
resources :tags
resources :kategoris
 resources :konkurrancers do
      collection do
        delete :delete_multiple
      end
    end
resources :reklamers
   end

最佳答案

您可能需要将其更改为:

<%= link_to 'Destroy', :action => 'destroy', :id => konkurrancer.id, :method => :delete %>

或者如果您使用restful路由,比如:
<%= link_to 'Destroy', delete_konkurrancer(:id => konkurrancer.id), :method => :delete %>

关于ruby-on-rails - Rails 3破坏链接不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6134988/

10-13 04:41