没有路由匹配 [GET] "/products"

No route matches [GET] "/products"

我遵循这个How To但是我没有路由匹配错误...

我有这个 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")

我假设请求在子域约束下被拒绝。我想你向 http://localhost:3000/produtcts, but you need some url like http://api.****/products. There is a guide how to do it locally http://shapeshed.com/developing-subdomain-rails-sites-locally/

提出了请求