ruby-on-rails - 使用设计令牌身份验证覆盖 Rails API 中的注册控制器时出现路由错误
问题描述
我正在尝试发送 POST 请求(使用 Postman)以使用设计令牌身份验证注册新用户,并且我正在覆盖注册控制器以启用我自己的 JSON 响应。
我不断收到路由错误:
"status": 404,
"error": "Not Found",
"exception": "#<ActionController::RoutingError: uninitialized constant Overrides>"
这是我的注册控制器:
module Api
module V1
module Overrides
class RegistrationsController < DeviseTokenAuth::RegistrationsController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
warden.custom_failure!
render :json=> user.errors, :status=>422
end
end
end
end
end
end
这是我的路线文件:
Rails.application.routes.draw do
namespace :api do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'auth', controllers: {
registrations: 'overrides/registrations',
sessions: 'overrides/sessions'
}
end
end
end
我的路线哪里出错了?
解决方案
推荐阅读
- flutter - Flutter - 选择后 DropdownButton 值保持为空
- php - 将base64转换为真实图像并保存在文件夹php中
- android - 如何从 keytool 获取“不正确的密码”?
- javascript - 嵌入在 php 中的 Javascript 警报功能在客户端解释消息时存在问题
- ejb - 为什么查找我的托管 bean 失败?
- binding - XJB 绑定文件中的 XJC 范围
- c# - c# 登录凭据(非显式)可以与 wsmanconnectioninfo 一起使用吗?
- css - 加载资源失败:服务器响应状态为 500 () Spring mvc
- python-3.x - Python:对每五行b列数据求和并创建一个新列
- python - 在 elif 语句中调用函数