I'm trying to used devise_token_auth with active_admin. When running rails g active_admin:install User
I get the following error.
usr/local/lib/ruby/gems/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:578: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.
Rails.application.routes.draw do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
mount_devise_token_auth_for 'User', at: 'auth'
scope module: 'api' do
namespace :v1 do
resources :users, only: [:index, :show]
end
end
get '/docs' => redirect('/swagger/dist/index.html?url=/apidocs/api-docs.json')
end
I got it working by moving mount_devise_token_auth_for 'User', at: 'auth'
into the api scope. The answer was right , here.
Rails.application.routes.draw do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
constraints subdomain: 'api'do
scope module: 'api' do
namespace :v1 do
resources :users, only: [:index, :show]
mount_devise_token_auth_for 'User', at: 'auth'
end
end
get '/docs' => redirect('/swagger/dist/index.html?url=/apidocs/api-docs.json')
end
end