过滤器链因呈现或重定向的:validate_sign_up_params而停止

问题描述

我正在安装Devise,以在作为后端的Rails API上部署Login功能

我试图发布Postman的API请求,但收到以下错误

[错误消息] 不允许的参数::format 滤镜链因:validate_sign_up_params呈现或重定向而暂停

・请求(邮递员): POST“ http:// localhost:3000 / api / v1 / auth”

・ json { “ username”:“ hogehoge”, “ email”:“ [email protected]”, “密码”:“ 123456789” }


app / controllers / v1 / auth / registrations_controller.rb 
   module Api
      module V1
        module Auth
          class RegistrationsController < DevisetokenAuth::RegistrationsController
            private
            def sign_up_params
              params.permit(:username,:email,:password)
            end
            def account_update_params
              params.permit(:username,:email)
            end
    
          end
        end
      end
    end

解决方法

您应在请求中添加password_confirmation参数。

,

postman settings

在Postman上,发送数据的格式仅为“文本”,但像上面那样更改为“ JSON”,那么问题就解决了!