0
我在Rails中构建了一个API,我希望它能够被版本化。我routes.rb
文件包括:导致“不支持控制器名称”的名称空间下的Rails资源路由。
Rails.application.routes.draw do
namespace :V1 do
resources :users
end
end
我有我的/app/controllers/V1/users_controller.rb
下控制器,它有这样的内容:
module V1
class UsersController < ApplicationController
def index
render json: {message: "This is a test!"}
end
end
end
当我尝试运行在命令行中我得到以下错误轨道上的服务器:
`default_controller_and_action': 'V1/users' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use
我查看了错误消息给了我的链接,但它似乎是如何指定一个控制器使用资源。而不是这样做,Rails可以不从我的目录结构中自动确定它吗?
尝试使用小写字母命名空间(:V1) – infused 2014-10-04 17:48:49