我是 Rails 和模块/命名空间的新手
我的控制器的命名空间如下:
module Api
module V1
class PostsController < ApiController
ActiveModel::Serializers 在我的 app 文件夹中放置了一个“Serializers”文件夹,我在其中创建了包含以下代码的 post_serializer.rb:
class PostSerializer < ActiveModel::Serializer
attributes :id, :body, :category,
end
当我尝试访问 JSON 响应时,我得到:
NameError at /api/v1/posts
uninitialized constant Api::V1::PostsController::PostSerializer
这里有什么问题,将我的序列化程序与我的 API 版本一起命名空间的最佳方法是什么?