mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Fix JSON:API polymorphic type regression from v0.10.5
This commit is contained in:
parent
0fcb8a6cce
commit
cf29db34c6
@ -46,7 +46,14 @@ module ActiveModelSerializers
|
||||
if association.belongs_to? &&
|
||||
parent_serializer.object.respond_to?(association.reflection.foreign_key)
|
||||
id = parent_serializer.read_attribute_for_serialization(association.reflection.foreign_key)
|
||||
type = association.reflection.type.to_s
|
||||
if association.polymorphic?
|
||||
# We can't infer resource type for polymorphic relationships from the serializer.
|
||||
# We can ONLY know a polymorphic resource type by inspecting each resource.
|
||||
serializer = association.lazy_association.serializer
|
||||
type = serializer.json_key
|
||||
else
|
||||
type = association.reflection.type.to_s
|
||||
end
|
||||
ResourceIdentifier.for_type_with_id(type, id, serializable_resource_options)
|
||||
else
|
||||
# TODO(BF): Process relationship without evaluating lazy_association
|
||||
|
||||
Loading…
Reference in New Issue
Block a user