Devise NoMethodError 'for' ParameterSanitizer

后端 未结 1 1559
别那么骄傲
别那么骄傲 2021-02-05 16:08

I\'m going nuts with an error I\'m getting every time I try to sing in/sing up on my web.

Heroku logs:

Started GET \"/users/sign_in\" for 201.235.89.150          


        
相关标签:
1条回答
  • 2021-02-05 16:43
    class ApplicationController < ActionController::Base    
      before_action :configure_permitted_parameters, if: :devise_controller?
    
      protected
    
      def configure_permitted_parameters
        devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :email])
        devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :phone, :email, bank_attributes: [:bank_name, :bank_account]])
      end
    end
    

    "The .for method is deprecated in 4.1 +

    The first arg is the action name. :sign_up is for creating new Devise resources (such as users), and :account_update is for editing/updating the resource.

    The second arg, :keys contains an array of the parameters you allow.

    If you want nested_attributes, there is an example in :account_update, you put a separate array in with the key being _attributes."

    0 讨论(0)
提交回复
热议问题