我的 routes.rb 文件中有以下内容:
match "/service/:product" => "products#show_name"
match "/products/custom/" => "products#custom"
match "/products/customform" => "products#customform"
match "/categories" => "products#categories"
match "/search" => "products#search"
match "/about" => "products#about"
get 'category/:tag', to: 'products#category', as: :tag
resources :products do
resources :reviews
end
我正在尝试访问 URL“/service/birchbox”。当我这样做时,我收到一条错误消息
No route matches {:action=>"edit", :controller=>"products"}
关于如何解决这个问题的任何建议?我试图让这个 url 转到列出的第一条路线(到控制器 products#show_name 但由于某种原因要编辑)。
这是我在控制台中看到的更多信息。似乎它将显示_name,但我不断收到错误消息。
Processing by ProductsController#show_name as HTML
Parameters: {"product"=>"birchbox"}
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."slug" = 'birchbox' LIMIT 1
(0.1ms) SELECT COUNT(*) FROM "reviews" WHERE "reviews"."product_id" = 14
ActsAsTaggableOn::Tag Load (0.1ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = 14 AND "taggings"."taggable_type" = 'Product' AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL)
Rendered products/show_name.html.erb within layouts/application (97.3ms)
Completed 500 Internal Server Error in 164ms
ActionController::RoutingError (No route matches {:action=>"edit", :controller=>"products"}):
app/views/products/show_name.html.erb:42:in `_app_views_products_show_name_html_erb___2110533700820522490_70197663436420'