rails 6.0.3 (standard mode, not API)

I'm trying token authentication using devise_token_auth.
The method of registering using curl or postman is often introduced, but I want to transition from the login screen of the web to the registration screen, but I can not transition to the registration screen before registering on the web. in trouble. (User registration has been confirmed using curl)

Hit the registration screen/ api/v1/auth/sign_upI have confirmed the routing to to as follows, but even if I hit this URL, a Routing Error and an error occur and I can not transition to the corresponding screen.

Below is the routing and controller code, as well as the hierarchy.

# routes.rb
Rails.application.routes.draw do
  namespace: api do
    namespace: v1 do
      mount_devise_token_auth_for "User", at: "auth", controllers: {
#controller controllers/api/v1/auth/resisrations_controller.rb
class Api :: V1 :: Auth :: RegistrationsController<DeveiseTokenAuth :: RegistrationsController
#view hierarchy views/api/v1/auth/resitrations/new.html.erb

Embarrassing story, I wrote by imitating the appearance There are several things I do not understand personally
First of all,at: "auth" and controllers: {registrations:'auth/registrations'}
I don't understand the grammar.
I did some research, but I'm not sure what kind of routing this option has at and controllers, so I can't find it, so I should place the controllers and views in what hierarchy. I don't know the controller in the first place.

Another onedevise_token_auth github
I went to see it, but I don't think I can see the corresponding action (new) on the registration screen.
I mean, now icontrollers/api/v1/auth/resistrations_controller.rb
soDeviseTokenAuth :: RegistrationsControllerSince it inherits from, it should be in a state where this devise tokenauth method can be used, but since there is no new action in the first place, I thought that transition could not be done.
Is it necessary to create a new action rather than override the new action when using devisetokenauth?

How can I modify the above to open the registration screen (/ api/v1/auth/sign_up) locally?
We apologize for the inconvenience, and thanks for your cooperation.

  • Answer # 1

    devise_token_authI haven't used, so I don't know much about it.
    The answer will be as far as you can understand, so if you have more details, it would be better to have a look there.

    I can't find the corresponding action (new) on the registration screen

    This gem looked like a gem to implement the backend API processing for that authentication when you want to implement the frontend outside of rails and implement the authentication process in the backend rails.

    So, maybe, I think it's possible that the gem developer decided that "API call is not necessary yet" (?) At the timing of displaying the registration screen.
    If this is the case, there is no action for the "registration screen" in this gem, and it is possible that you will have to implement it all yourself.

    If anyone has actually used it, it may be a little clearer ...

    At what level should the controller and view be placed?

    For this, I think you should refer to the rightmost column of the image you have posted.
    As written there,


    I think it will be.

    The left column is the Path of the URL that comes to the server, and when that Path is received, I think that it is the role of routing to skip the process to the action in the controller in the rightmost column.

    # routes.rb
    mount_devise_token_auth_for "User", at: "auth", controllers: {

    Do you need this? ??

    Looking at the following article, if there is no problem with the default routing, it seems that it is not necessary to add it to the route.

    〇 Create API easily and quickly using devise token auth 1

    〇 When you want to edit the devise controller
    https://qiita.com/Masahiro_T/items/6bc49a625b437a7c2f45#devise%E3%81%AE%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83% BC% E3% 83% A9% E3% 83% BC% E3% 82% 92% E7% B7% A8% E9% 9B% 86% E3% 81% 97% E3% 81% 9F% E3% 81% 84% E6% 99% 82

    You may consider the description in routes with that in mind.