Closed dmolesUC closed 2 years ago
Hey, thanks for the issue @dmolesUC
You're right, this needs to be updated, as we already did in https://github.com/jsonapi-serializer/jsonapi-serializer/pull/75
(probably as easy as to just call the jsonapi-serializer
implementation :thinking: )
Happy to merge it if you have time to prepare a PR.
@stas Will do. I had a look at calling the json-serializer
implementation, but since it's inside a class_methods
block it was nontrivial, so I'm just going to do it the easy way for now.
Expected Behavior
size
attribute is recognized as not a collectionActual Behavior
size
attribute mistakenly believed to be a collection due to this heuristic inJSONAPI::Rails.is_collection?
NoMethodError
when attempting to callany?
here inJSONAPI::Rails.add_renderer!
Steps to Reproduce the Problem
size
of typestring
.render jsonapi: @the_instance
in a controller method.Possible solutions
Consider using
resource.is_a?(Enumerable)
instead ofrespond_to?(:any?)
. This seems to be what jsonapi-serializer does now after first realizingsize
was a problem and tryingeach
instead, then deciding that was more trouble than it was worth.Specifications