Johshi Johshi - 1 year ago 79
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?


def accept_resource

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)

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 Source

Method for was deprecated and successfully removed from Devise.

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