mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
adds polymorphic option to association definition which includes association type in serializer
regen gemlock regen gemlock better variable naming rubocop fixes adds to changelog adds empty relationship and has_many polymorph tests indent test cleaning -rubocop rubocop rubocop rubocop changelog remove silly .DS fix roque failure fix
This commit is contained in:
@@ -45,7 +45,14 @@ module ActiveModelSerializers
|
||||
return unless association.serializer && association.serializer.object
|
||||
|
||||
opts = instance_options.merge(include: @include_tree[association.key])
|
||||
Attributes.new(association.serializer, opts).serializable_hash(options)
|
||||
relationship_value = Attributes.new(association.serializer, opts).serializable_hash(options)
|
||||
|
||||
if association.options[:polymorphic] && relationship_value
|
||||
polymorphic_type = association.serializer.object.class.name.underscore
|
||||
relationship_value = { type: polymorphic_type, polymorphic_type.to_sym => relationship_value }
|
||||
end
|
||||
|
||||
relationship_value
|
||||
end
|
||||
|
||||
# Set @cached_attributes
|
||||
|
||||
Reference in New Issue
Block a user