I'm using the gem devise-token-auth which is working great.
At this moment, for signing up I use the original routes which is /api/v1/auth
in my case :
# routes.rb
namespace :api do
namespace :v1 do
mount_devise_token_auth_for 'User', as: 'v1', at: 'auth', controllers: {
token_validations: 'api/v1/users/token_validations',
confirmations: 'api/v1/users/confirmations',
registrations: 'api/v1/users/registrations',
passwords: 'api/v1/users/passwords',
sessions: 'api/v1/users/sessions'
}
end
end
Now I want to change the default sign up URL for /api/v1/auth/signing_up
for example, but when I add to my file the post
line, even if rails routes
returns what I want, I got an error :
# routes.rb
post "/auth/signing_up" => "users/registrations#create"
# rails routes
# Default route
api_v1_user_registrationPOST /api/v1/auth(.:format) api/v1/users/registrations#create
# New created route
api_v1_auth_signing_up POST /api/v1/auth/signing_up(.:format) api/v1/users/registrations#create
# Error when POST
AbstractController::ActionNotFound (Could not find devise mapping for path "/api/v1/auth/signing_up".
I am using this for different type of sign up and it is working good,
namespace :api, constraints: { format: 'json' } do
namespace :v1 do
devise_scope :user do
post 'auth/teacher_sign_up', to: 'registration#teacher_sign_up'
end
devise_scope :user do
post 'auth/student_sign_up', to: 'sessions#teacher_sign_up'
end
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.