Devise and Strong Parameters

后端 未结 4 532
既然无缘
既然无缘 2020-12-05 09:47

I would like to know how to integrate both of this gems(devise + Strong Parameters), since strong params will likely be added to the rails core in 4.0

any help is we

4条回答
  •  清歌不尽
    2020-12-05 10:23

    You can also try this one its include nested params permit

    class ApplicationController < ActionController::Base
     before_action :configure_permitted_parameters, if: :devise_controller?
    
      protected
    
      def configure_permitted_parameters
       devise_parameter_sanitizer.permit(:sign_up, keys: [:username,:phone])
      # permit nested attributes
      # devise_parameter_sanitizer.permit(:sign_up, keys: 
      # [:username,:phone,profile_attributes:[:firstname, :lastname]])
      end
    end
    

    This will work with rails 4 and 5 devise and rails

提交回复
热议问题