0
在rails应用程序中创建API时出现错误。错误是:未初始化的常量API :: V1 :: PopularSchoolsController - Rails API
ActionController::RoutingError (uninitialized constant
API::V1::PopularSchoolsController):
我的文件夹结构是:
我的路线:
namespace :api, defaults: {format: :json} do
namespace :v1 do
resources :popular_schools
end
end
控制器:
class API::V1::PopularSchool::PopularSchoolsController < ApplicationController
def index
@popular_schools = PopularSchool.all
respond_to do |format|
format.json { render json: @popular_schools }
end
end
end
是inflections.rb:
ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
inflect.acronym 'API'
inflect.acronym 'V1'
end