在
我已启用了Javascript。
请建议。
index.html.erb
文件中,我展示了所有的产品,并在每个产品旁边放置了编辑
和删除
操作。<% @products.each do |product| %>
...
<%= link_to("Edit", edit_product_path(product.id), :class => 'action') %>
<%= link_to("Delete", product, :method => :delete, :class => 'action') %>
...
<% end %>
Edit
链接正常工作,但Delete
链接无法正常工作。我收到以下错误:
Unknown action
The action 'show' could not be found for ProductsController
我猜是因为请求方法是GET而不是DELETE。但是,如果我明确设置:method => :delete
,我不知道为什么会这样发生。
routes.rb
非常简单:
root :to => "products#index"
resources :products
我已启用了Javascript。
请建议。