ruby on rails - Changing URL for devise_token_auth sign_in -


i use devise_token_auth , trying change users sign_in url. have sessions_controller in api/v2/ folder , devise_token_auth routes below:

routes:

namespace :api     namespace :v2         mount_devise_token_auth_for 'user', at: 'users', :controllers => {           :registrations => 'api/v2/registrations',           :confirmations => 'api/v2/confirmations',           :passwords => 'api/v2/passwords',           :sessions => 'api/v2/sessions'}          post 'users/sign-in', to: 'sessions#create'     end end 

when rake routes the route wish:

api_v2_users_sign_in post /api/v2/users/sign-in(.:format) api/v2/sessions#create

but, when try hit url following error:

abstractcontroller::actionnotfound (could not find devise mapping path "/api/v2/users/sign-in". may happen 2 reasons:  1) forgot wrap route inside scope block. example:    devise_scope :user     "/some/route" => "some_devise_controller"   end  2) testing devise controller bypassing router.    if so, can explicitly tell devise mapping use:     @request.env["devise.mapping"] = devise.mappings[:user]  ):  /users/gokul/.rvm/gems/ruby-2.3.0@rails5.0/bundler/gems/devise-bcdd54cc5ebd/app/controllers/devise_controller.rb:88:in `unknown_action!' /users/gokul/.rvm/gems/ruby-2.3.0@rails5.0/bundler/gems/devise-bcdd54cc5ebd/app/controllers/devise_controller.rb:63:in `assert_is_devise_resource!' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:382:in `block in make_lambda' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:169:in `block (2 levels) in halting' actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:callbacks>' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:170:in `block in halting' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `block in call' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `each' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `call' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:101:in `__run_callbacks__' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:90:in `run_callbacks' actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (5.0.0.rc1) lib/action_controller/metal/rescue.rb:31:in `process_action' actionpack (5.0.0.rc1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' activesupport (5.0.0.rc1) lib/active_support/notifications.rb:164:in `block in instrument' activesupport (5.0.0.rc1) lib/active_support/notifications/instrumenter.rb:21:in `instrument' activesupport (5.0.0.rc1) lib/active_support/notifications.rb:164:in `instrument' actionpack (5.0.0.rc1) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (5.0.0.rc1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action' activerecord (5.0.0.rc1) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (5.0.0.rc1) lib/abstract_controller/base.rb:126:in `process' actionpack (5.0.0.rc1) lib/action_controller/metal.rb:190:in `dispatch' actionpack (5.0.0.rc1) lib/action_controller/metal.rb:262:in `dispatch' actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch' actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:32:in `serve' actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:39:in `block in serve' actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:in `each' actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:in `serve' actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:725:in `call' apipie-rails (0.3.6) lib/apipie/static_dispatcher.rb:65:in `call' actionview (5.0.0.rc1) lib/action_view/digestor.rb:12:in `call' apipie-rails (0.3.6) lib/apipie/extractor/recorder.rb:132:in `call' warden (1.2.6) lib/warden/manager.rb:35:in `block in call' warden (1.2.6) lib/warden/manager.rb:34:in `catch' warden (1.2.6) lib/warden/manager.rb:34:in `call' rack (2.0.0.rc1) lib/rack/etag.rb:25:in `call' rack (2.0.0.rc1) lib/rack/conditional_get.rb:38:in `call' rack (2.0.0.rc1) lib/rack/head.rb:12:in `call' activerecord (5.0.0.rc1) lib/active_record/migration.rb:552:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:97:in `__run_callbacks__' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:90:in `run_callbacks' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:36:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' railties (5.0.0.rc1) lib/rails/rack/logger.rb:36:in `call_app' railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in `block in call' activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:in `block in tagged' activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:in `tagged' railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/request_id.rb:24:in `call' rack (2.0.0.rc1) lib/rack/runtime.rb:22:in `call' activesupport (5.0.0.rc1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:in `call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/static.rb:136:in `call' rack (2.0.0.rc1) lib/rack/sendfile.rb:111:in `call' rack-cors (0.4.0) lib/rack/cors.rb:80:in `call' railties (5.0.0.rc1) lib/rails/engine.rb:522:in `call' puma (3.2.0) lib/puma/configuration.rb:227:in `call' puma (3.2.0) lib/puma/server.rb:561:in `handle_request' puma (3.2.0) lib/puma/server.rb:406:in `process_client' puma (3.2.0) lib/puma/server.rb:271:in `block in run' puma (3.2.0) lib/puma/thread_pool.rb:111:in `block in spawn_thread'  

i need url api/v2/users/sign-in. please me.

thanks..

i solved adding default scope in routes user below:

      mount_devise_token_auth_for 'user', at: 'users', :controllers => {           :registrations => 'api/v2/registrations',           :confirmations => 'api/v2/confirmations',           :passwords => 'api/v2/passwords'       }, skip: [:sessions]        devise_scope :api_v2_user         'users/sign-in', to: 'sessions#new'         post 'users/sign-in', to: 'sessions#create'         delete 'users/sign-out', to: 'sessions#destroy'       end 

if api namespaced important use namespaced devise_scope..

got answer link: https://stackoverflow.com/a/33503944/4172728


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -