Strong parameters with Rails and Devise

后端 未结 3 1678
野性不改
野性不改 2020-12-07 18:52

I am using the rails 4.0 branch of devise along with ruby 2.0.0p0 and Rails 4.0.0.beta1.

This is the kind of question where I am checking if I\'m doing it the right

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 19:00

    It works very nice with adding an module in config/initializers with all parameters like this

    module DevisePermittedParameters
      extend ActiveSupport::Concern
    
      included do
        before_filter :configure_permitted_parameters
      end
    
      protected
    
      def configure_permitted_parameters
        devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }
      end
    
    end
    
    DeviseController.send :include, DevisePermittedParameters
    

提交回复
热议问题