Sancho Sancho - 1 year ago 42
Ruby Question

Rails 5, Route declare but not found

In my routes config i have:

constraints subdomain: 'api' do
scope module: 'api' do
namespace :v1 do
get '/me', to: 'users#me'

bin/rake routes return

v1_me GET /v1/me(.:format) api/v1/users#me {:subdomain=>"api"}

When i try the uri http://localhost:3000/v1/me, http://localhost:3000/api/v1/me or http://localhost:3000/me with postman i have a 404 not found error.

ActionController::RoutingError (No route matches [GET] "/v1/me"):

What is wrong with my code ?


You have a constraint set for subdomain. So you'll have to access it via something like api.localhost:3000 Which won't work out of the box for any dev env.

Your routes makes sure that the specified endpoint is only defined for the api subdomain.

You can try these:


You might need to add entries in your hosts file to point any custom domain to