1, edit the /etc/hosts file
127.0.0.1 api.localhost
2, routes.rb
namespace :api, path: '', constrains: { subdomain: 'api' } do
resources :users
end3, inflections.rb
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
end