我遵循这个How To但我没有路由匹配错误...无路由匹配[GET] “/产品”
我有这样的routes.rb:
# config/routes.rb
require 'api_constraints'
Rails.application.routes.draw do
namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/' do
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
resources :products, only: [:index, :show, :create, :destroy]
end
end
end
耙路线:
api_products GET /products(.:format) api/v1/products#index {:format=>:json, :subdomain=>"api"}
POST /products(.:format) api/v1/products#create {:format=>:json, :subdomain=>"api"}
api_product GET /products/:id(.:format) api/v1/products#show {:format=>:json, :subdomain=>"api"}
DELETE /products/:id(.:format) api/v1/products#destroy {:format=>:json, :subdomain=>"api"}
这是错误:
ActionController::RoutingError (No route matches [GET] "/products")
显示你的错误,当你得到它,并添加你的'routes.rb'代码问题。 –
在我的描述中有链接... – SaroVin
如果有人在这里读到你的问题,并且(天堂禁止)github不在了。他/她不能完全理解你的问题。 – Matthias