Johshi Johshi - 4 months ago 23
Ruby Question

Add additional fields to the list of permitted ones in an devise Invitation controller

I've some additional fields to the "accept inviation form" and I need to permit them in a controller. I did this according to the documentation:

class Users::InvitationsController < Devise::InvitationsController
before_filter :configure_permitted_parameters, if: :devise_controller?

private

def accept_resource
resource_class.accept_invitation!(update_resource_params)
end

def configure_permitted_parameters

# error here
devise_parameter_sanitizer.for(:accept_invitation).concat [:field1, :field2, :field3]

devise_parameter_sanitizer.for(:accept_invitation) do |u|
u.permit(:field1, :field2, :field3, :password, :password_confirmation, :invitation_token)
end
end


I need to allow ":field1, :field2, :field3". Am I doing it right? I have an error

undefined method `for' for #<Devise::ParameterSanitizer:0x007f20fe0d5220> Did you mean? fork

Answer

Method for was deprecated and successfully removed from Devise.

Use permit/sanitize instead, or downgrade to 4.0 (not recommended).