Skip to content

Commit

Permalink
disable static includes checks when using polymorphic relations
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas committed Sep 13, 2019
1 parent df4e6d2 commit 311cd15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/fast_jsonapi/object_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ def validate_includes!(includes)
relationships_to_serialize = klass.relationships_to_serialize || {}
relationship_to_include = relationships_to_serialize[parsed_include]
raise ArgumentError, "#{parsed_include} is not specified as a relationship on #{klass.name}" unless relationship_to_include
klass = relationship_to_include.serializer.to_s.constantize unless relationship_to_include.polymorphic.is_a?(Hash)
if relationship_to_include.polymorphic.is_a?(Hash)
# static check is not possible since the serializer is defined based on the instance class
return
else
klass = relationship_to_include.serializer.to_s.constantize
end
end
end
end
Expand Down

0 comments on commit 311cd15

Please sign in to comment.