0

I am trying to add a new column to the devise user model. But I'm getting an error to this file. I ran a migration to change the column, added the text fields to the view already. Thank you

class ApplicationController < ActionController::Base
  before_action :configure_devise_permitted_parameters, if:        :devise_controller?

  protected

  def configure_devise_permitted_parameters
    registration_params = [:full_name, :email, :password, :password_confirmation]

     if params[:action] == 'update'
        devise_parameter_sanitizer.for(:account_update) { 
        |u| u.permit(registration_params << :current_password)}
    else
        if params[:action] == 'create'
            devise_parameter_sanitizer.for(:sign_up) { 
            |u| u.permit(registration_params) 
        }
    end
  end

 end
koz
  • 195
  • 1
  • 13
  • Looks like devise has changed: http://stackoverflow.com/questions/37341967/rails-5-undefined-method-for-for-devise-on-line-devise-parameter-sanitizer – Taryn East Sep 09 '16 at 07:05

2 Answers2

0

Parameter Sanitizer API has changed for Devise 4

Documentation for Devise 4

You need to replace for with permit:

devise_parameter_sanitizer.permit(:sign_up) { 
        |u| u.permit(registration_params) 
    }

Documentation for Devise 3

Your current method should work in Devise 3 i.e :

devise_parameter_sanitizer.for(:sign_up) { 
        |u| u.permit(registration_params) 

Hope it works!

Community
  • 1
  • 1
dp7
  • 6,651
  • 1
  • 18
  • 37
0

for method is deprecated in the latest devise version , so you need to use permit instead of for

Chakreshwar Sharma
  • 2,571
  • 1
  • 11
  • 35