Strong parameters with Rails and Devise

后端 未结 3 1674
野性不改
野性不改 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:21

    For Rails 5, Devise 4 Use this:

    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, :password, :password_confirmation])
      end
    end
    

    Reference

提交回复
热议问题