Saving custom fields in devise User model in rails 4

前端 未结 4 1032
名媛妹妹
名媛妹妹 2021-02-05 20:24

I made a devise User model and added additional fields to it. When I create and account everything works fine, only with email, pw and pw conf.

I then want to allow the

4条回答
  •  自闭症患者
    2021-02-05 21:21

    In Rails4 we have strong parameters so please

    Add following line to your application_controller.rb

    before_filter :configure_devise_params, if: :devise_controller?
      def configure_devise_params
        devise_parameter_sanitizer.for(:sign_up) do |u|
          u.permit(:first_name, :last_name, :gender, :email, :password, :password_confirmation)
        end
      end
    

提交回复
热议问题