无法在设计#encept邀请中允许其他参数

时间:2016-07-31 07:58:59

标签: ruby-on-rails ruby devise

我无法在invite#accept中允许其他参数。我设置了一切,这里是一个控制器。 但是在方法accept_resource中,仍然只接受了3个旧参数,其他参数虽未出现在表格中,但仍未通过。

class MyInvitationsController < Devise::InvitationsController
  before_filter :configure_permitted_parameters, if: :devise_controller?
  before_filter :update_sanitized_params, only: [:edit, :update]

  def edit
    puts "edit...."
    super
  end

  private

  def accept_resource
    puts "accept_resource..."
    resource = resource_class.accept_invitation!(update_resource_params)

    # but it still permits only :password, :password_confirmation and :invitation_token
    resource
  end

  protected

  def configure_permitted_parameters
    puts "configure_permitted_parameters..."
    devise_parameter_sanitizer.permit(:sign_up, keys: [:aaa, :bbb, :ccc, :password, :password_confirmation, 
                                      :invitation_token])

  end

  def update_sanitized_params
    puts "update_sanitized_params..."

    devise_parameter_sanitizer.permit(:sign_up, keys: [:aaa, :bbb, :ccc, :password, :password_confirmation, 
                                      :invitation_token])

如何解决这个问题? 我使用设计4.2和devise_invitable 1.6

1 个答案:

答案 0 :(得分:0)

尝试删除

 if: :devise_controller?
在你的before_filter中

,因为你不是设计控制器。