在设计邀请控制器中将其他字段添加到允许的列表中

时间:2016-07-29 13:49:19

标签: ruby-on-rails ruby devise

我在"接受邀请表格"我需要在控制器中允许它们。我根据文档做到了这一点:

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

我需要允许&#34;:field1,:field2,:field3&#34;。我做得对吗?我有一个错误

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

1 个答案:

答案 0 :(得分:0)

for方法Devisedeprecated and successfully removed

改为使用permit/sanitize,或降级为4.0(不推荐)。