我正在使用宝石jsonapi-resources
0.10.5
。
这是我的资源:
class ProjectResource < JSONAPI::Resource
attributes :name
end
这是我的控制器:
class V2::ProjectController < V2::BaseController
def index
project = Project.find(1)
JSONAPI::ResourceSerializer.new(ProjectResource).serialize_to_hash(ProjectResource.new(project, nil), nil)
end
end
我得到这个错误:
NoMethodError in V2::ProjectTypesController#index undefined method `serialize_to_hash' for #JSONAPI::ResourceSerializer:0x00007ffabcc336b0
我只是在关注文档:
https://jsonapi-resources.com/v0.10/guide/serializer.html
知道有什么问题吗?