0

私のアプリ以外が以前に動作していた場所でエラーが発生しているため、エラーはルートにあるため、わかりません。

ActionController::RoutingError (No route matches {:action=>"show", :controller=>"products", :id=>#<Product id: 10, title: "", code: "", description: "", price: nil, created_at: "2013-06-01 18:52:16", updated_at: "2013-06-01 18:52:16", permalink: nil, image_1_file_name: nil, image_1_content_type: nil, image_1_file_size: nil, image_1_updated_at: nil, image_2_file_name: nil, image_2_content_type: nil, image_2_file_size: nil, image_2_updated_at: nil, image_3_file_name: nil, image_3_content_type: nil, image_3_file_size: nil, image_3_updated_at: nil, image_4_file_name: nil, image_4_content_type: nil, image_4_file_size: nil, image_4_updated_at: nil, image_5_file_name: nil, image_5_content_type: nil, image_5_file_size: nil, image_5_updated_at: nil, image_6_file_name: nil, image_6_content_type: nil, image_6_file_size: nil, image_6_updated_at: nil, image_7_file_name: nil, image_7_content_type: nil, image_7_file_size: nil, image_7_updated_at: nil, image_8_file_name: nil, image_8_content_type: nil, image_8_file_size: nil, image_8_updated_at: nil, weight: nil, width: nil, height: nil, length: nil>}):
  app/views/admin/products/index.html.erb:23:in `_app_views_admin_products_index_html_erb__949052465_2267215500'
  app/views/admin/products/index.html.erb:12:in `each'
  app/views/admin/products/index.html.erb:12:in `_app_views_admin_products_index_html_erb__949052465_2267215500'

私のビューでは表示するアンカーがないため、興味深いです。ビューは次のとおりです。

<h4>Produtos</h4>
<%= link_to 'Criar produto',new_admin_product_path %>
<table class="table table-striped">
    <tr>
        <td></td>
        <td>Nome do Produto</td>
        <td>Categorias</td>
        <td>Preço</td>
        <td></td>
        <td></td>
    </tr>
<% @products.each do |p| %>
    <tr>
    <td><%= image_tag p.image_1.url(:thumb),:height => 30 %></td>
    <td><%= p.title %></td>
    <td>
    <% p.categories.each do |a| %>
      <%= a.name %> 
    <% end %>
    </td>
    <td><%= to_currency p.price %></td>
    <td><%= link_to "Editar",edit_admin_product_path(p.id) %>
    <%= link_to "Excluir",p,:method => :delete %></td>
    </tr>
<% end %>
<table>

私のルートではこれです:

  namespace :admin do  
    get '', :to => 'dashboard#index', :as => '/'
    resources :products do 
      member do
        delete :del_p_cat
      end
    end
    resources :categories,:except => [:show]
    resources :users
  end

put :except => [:show] を試してみましたが、同じエラーが発生しました。アクション show を呼び出すものがない場合は意味がありません。

私のルートでは、次を実行するとショーが表示されますrake routes

 admin_product GET    /admin/products/:id(.:format)                        admin/products#show

および名前空間管理者を除外:

        product GET    /products/:id(.:format)                              products#show

このエラーは非常に基本的であり、ネストされたフォームをインストールすると、少し時間がかかるため理解できません。ルートが変更されていないため、わかりません。

4

2 に答える 2

0

この行にエラーがあるようです:

link_to "Excluir", p, :method => :delete

そのはず

link_to "Excluir", [:admin, p],:method => :delete
于 2013-06-01T19:56:07.407 に答える