Open caseyprovost opened 6 years ago
@caseyprovost I thinik that way doesn't work, you should move mount_devise_token_auth_for
outside the scope, and define 2 with different at
, eg: at: '/api/v1/auth'
and at: '/api/v2/auth'
I gave this a whirl and am still experiencing errors.Below is my router code and result.
mount_devise_token_auth_for 'User', at: 'v1/auth', controllers: {
sessions: 'v1/sessions',
omniauth_callbacks: 'v1/devise_token_auth/omniauth_callbacks'
}
mount_devise_token_auth_for 'User', at: 'v2/auth', controllers: {
sessions: 'v2/sessions',
omniauth_callbacks: 'v2/devise_token_auth/omniauth_callbacks'
}
/Users/casey/.rvm/gems/ruby-2.4.1/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:584:in `add_route': Invalid route name, already in use: 'new_user_session'
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created (ArgumentError)
@MaicolBen ^^
@caseyprovost You were right with your first approach (maybe there is a way to get mine working as well), as the error states, you have to define 2 different as
, e.g as: 'v1'
For future reference, you can mount it like:
scope 'general', as: 'general' do
mount_devise_token_auth_for 'User', at: 'auth', controllers: {
sessions: 'general/sessions'
}
end
Hi there!
The problem I am having hopefully is a simple one. I am attempting to mount devise_token_auth a second time in the
v2
namespace, but cannot get it to allow me to do so. It is pretty important since we are starting the rebuild of our API and need auth changed a bit. Is this a bug or a known constraint of the library?Routes
Gem Details
Stack Trace