我不知道是因为什么,但我的应用程序在以前工作的地方出现错误,错误出现在路线中。
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
我尝试放置 :except => [:show] 但同样的错误,如果没有调用动作秀就没有意义。
当我执行以下命令时,在我的路线中有显示rake routes
:
admin_product GET /admin/products/:id(.:format) admin/products#show
并没有命名空间管理员:
product GET /products/:id(.:format) products#show
这个错误非常重要,我没有理解,因为只有一点时间工作,当我安装嵌套表单时,我不知道更多,因为我不改变什么路线。