JSONAPI Resources: undefined method serialize_to_hash

390 Views Asked by At

I am using the gem jsonapi-resources 0.10.5.

This is my resource:

class ProjectResource < JSONAPI::Resource
  attributes :name
end

and this is my controller:

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

and I get this error:

NoMethodError in V2::ProjectTypesController#index undefined method `serialize_to_hash' for #JSONAPI::ResourceSerializer:0x00007ffabcc336b0

I am just following the docs:

https://jsonapi-resources.com/v0.10/guide/serializer.html

Any idea what is wrong?

0

There are 0 best solutions below