-
Notifications
You must be signed in to change notification settings - Fork 36
Undefined method serialize_to_hash on Serializer page #53
Copy link
Copy link
Open
Description
guide/serializer.html suggests that we can do:
post = Post.find(1)
JSONAPI::ResourceSerializer.new(PostResource).serialize_to_hash(PostResource.new(post, nil))
But when I do the equivalent in 0.10.2, I get the error:
undefined method `serialize_to_hash'
for #<JSONAPI::ResourceSerializer:0x00007fae9ec1cbf0>
Looking through the source of JSONAPI::ResourceSerializer, #object_hash seems to be the currently-available method that meets that need. The code succeeds for me with the following change:
post = Post.find(1)
JSONAPI::ResourceSerializer.new(PostResource).object_hash(PostResource.new(post, nil), nil)
(Note that #object_hash takes two arguments, so we pass nil for the second.)
I would PR this change to the page, but I'm unsure of the correct changes for the rest of the page.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels