GET on /auth/sign_up
is not functioning as expected. Getting the following 404 error
{
"status": 404,
"error": "Not Found",
"exception": "#<AbstractController::ActionNotFound: The action 'new' could not be found for DeviseTokenAuth::RegistrationsController>",
"traces": #too long to post; 46 traces; none includes user created files
}
Here's everything I did
Created a new Rails API project
rails new untitled --javascript=jquery --api
Added this to
Gemfile
#authentication gem 'devise' gem 'omniauth' gem 'devise_token_auth'
Ran the following
bundle install rails generate devise_token_auth:install User auth rails db:migrate rails s
Tested the url
localhost:3000/auth/sign_up
from browser and fromPostman
My routes.rb
Rails.application.routes.draw do
mount_devise_token_auth_for 'User', at: 'auth'
end
My rails routes output
Prefix Verb URI Pattern Controller#Action
new_user_session GET /auth/sign_in(.:format) devise_token_auth/sessions#new
user_session POST /auth/sign_in(.:format) devise_token_auth/sessions#create
destroy_user_session DELETE /auth/sign_out(.:format) devise_token_auth/sessions#destroy
user_password POST /auth/password(.:format) devise_token_auth/passwords#create
new_user_password GET /auth/password/new(.:format) devise_token_auth/passwords#new
edit_user_password GET /auth/password/edit(.:format) devise_token_auth/passwords#edit
PATCH /auth/password(.:format) devise_token_auth/passwords#update
PUT /auth/password(.:format) devise_token_auth/passwords#update
cancel_user_registration GET /auth/cancel(.:format) devise_token_auth/registrations#cancel
user_registration POST /auth(.:format) devise_token_auth/registrations#create
new_user_registration GET /auth/sign_up(.:format) devise_token_auth/registrations#new
edit_user_registration GET /auth/edit(.:format) devise_token_auth/registrations#edit
PATCH /auth(.:format) devise_token_auth/registrations#update
PUT /auth(.:format) devise_token_auth/registrations#update
DELETE /auth(.:format) devise_token_auth/registrations#destroy
user_confirmation POST /auth/confirmation(.:format) devise_token_auth/confirmations#create
new_user_confirmation GET /auth/confirmation/new(.:format) devise_token_auth/confirmations#new
GET /auth/confirmation(.:format) devise_token_auth/confirmations#show
auth_validate_token GET /auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
auth_failure GET /auth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks
omniauth_failure GET|POST /omniauth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /auth/:provider(.:format) redirect(301)
Other things I've noticed
- Other routes, for eg.
/auth/sign_in
work flawlessly and I'm able to sign in successfully for the users I've created usingRails Console
Looks like a similar error caused this post, but not caused due tosubdomain constraints
inroutes.rb
Some have mentioned in the comments even after doing like what's given in the answer did not get rid of 404
Here's what I tried then
- Tried
rails generate devise:controller users
- Uuncommmented
new
section inRegistrationsController
- Added some random
render :json
s which always throws up an empty JSON with status 200 with weirdbin/rails: No such file or directory
error on terminal - Tried to get rid of it using
rails app:update:bin
, nothing changes :(
What am I doing wrong?