我正在编写一个自定义注册devise
控制器,由于此错误,我在添加允许的参数时遇到问题(这是 Rspec 的输出,但手动发生相同的错误(:
Failure/Error: devise_parameter_sanitizer.permit(:sign_up, keys: [:nome, :password, :password_confirmation, :cnpj, :razao_social, :nome_fantasia, :email, :tipo_entidade_id])
NoMethodError:
undefined method `concat' for #<Proc:0x0055ca9fb2d850>
Did you mean? concern
完整控制器:
class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# POST /resource
def create
user_params = sign_up_params[:user_params]
entidade_params = sign_up_params[:entidade_params]
if !(User.exists?(email: user_params[:email]) || Entidade.exists?(cnpj: entidade_params[:cnpj]))
@entidade = Entidade.new(entidade_params)
@entidade.data_validade = 30.days.from_now
if @entidade.save
@user = User.new(user_params)
@user.entidade_id = @entidade.id
if @user.save
flash[:notice] = 'Usuario criado com sucesso.'
redirect_to root_path
end
end
end
end
protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:nome, :password, :password_confirmation, :cnpj, :razao_social, :nome_fantasia, :email, :tipo_entidade_id])
end
end
乍一看,这似乎是宝石中的错误,但似乎没有人遇到这个问题 - 谷歌没有返回任何相关内容。这是我的代码中的错误吗?
我不确定是否是这种情况,但是如果您复制参数清理器,例如在用户控制器中以及在应用程序控制器中使用它,则可能会发生此错误。
您可以在此处查看更详细的说明:GitHub 问题已关闭