Adding custom parameters to devise registration - unpermitted parameters

前端 未结 4 1114
谎友^
谎友^ 2020-12-05 19:38

I\'ve been trying to customize the devise register method to register with more parameters and also update more(no luck so far), but I always get Unpermitted parameter

4条回答
  •  無奈伤痛
    2020-12-05 19:46

    The accepted answer says the config should go in your applicationController but it can simply go in your user registration controller and you can specify that you only want to run it for create method and nothing else:

    
    class Users::RegistrationsController < Devise::RegistrationsController
      before_action :configure_sign_up_params, only: [:create]
    
      protected
    
      def configure_sign_up_params
        devise_parameter_sanitizer.permit(:sign_up, keys: [:enter_param_name_here])
      end
    end
    

提交回复
热议问题