I'm trying to make an application with devise auth, but i wanna use Inertia + VueJS instead of Rails views. I'm having a hard time to make this work, so far i made the custom controllers using rails generate devise:controllers users
The registrations controller
class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
layout false
# POST /resource
def create
super
end
protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end
end
The routes file
Rails.application.routes.draw do
devise_for :users, skip: :registrations
devise_scope :user do
post 'sign_up', to: 'users/registrations#create'
end
root 'home#index'
end
Application Controller
class ApplicationController < ActionController::Base
before_action :authenticate_user!
protect_from_forgery prepend: true
end
Ruby version: '2.6.5', Rails Version: '6.0.3.2'
I'm using Insomnia to make the requests, i'm passing just a json with name, email, password and password confirmation. This is the response i had Insomnia Response
This is because you create custom path for user registration, but still use default devise
controller inheritance on call super
that use default routes helper in some inner functions.
The simplest way to fix it - use devise instead of create your own routes
Remove that
devise_scope :user do
post 'sign_up', to: 'users/registrations#create'
end
And change devise_for
devise_for :users, controllers: {
registrations: 'users/registrations'
}