After creating a user registration and login screen with devise This method is for when you want to register / log in with information other than the default (email).
I edited the form on the view page, but there is a trap that I cannot register or log in to. please refer.
In the following cases, the keys of sing_up and account_update are changed.
class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters if resource_class == User devise_parameter_sanitizer.permit(:sign_up, keys: [:name,:email]) devise_parameter_sanitizer.permit(:sign_in,keys:[:email]) devise_parameter_sanitizer.permit(:account_update,keys:[:name,:email]) end end end
before_action :configure_permitted_parameters, if: :devise_controller?
before_action is a kind of filter, which is executed for all controllers by writing it in application.contoller.
: devise_contoller? is one of the helper methods that can be created when devise is generated. If you want to jump to the screen related to devise. This will launch configure_permitted_parameters on all devise screens.
This means that if it's a devise controller (if the return value of the devise_controller? Method is true), call configure_permitted_parameters.