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