-
Notifications
You must be signed in to change notification settings - Fork 65
Closed
Description
Expected Behavior
- Single model instance with
sizeattribute is recognized as not a collection
Actual Behavior
- Single model instance with
sizeattribute mistakenly believed to be a collection
due to this heuristic inJSONAPI::Rails.is_collection? - Serialization fails with
NoMethodErrorwhen attempting to callany?here inJSONAPI::Rails.add_renderer!
Steps to Reproduce the Problem
- Create a model with an attribute
sizeof typestring. - Try to serialize it, e.g. with
render jsonapi: @the_instancein a controller method.
Possible solutions
Consider using resource.is_a?(Enumerable) instead of respond_to?(:any?). This seems to be what jsonapi-serializer does now after first realizing size was a problem and trying each instead, then deciding that was more trouble than it was worth.
Specifications
- Version: 1.7.0
- Ruby version: 3.0.3
- jsonapi-serializer version: 2.2.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels