-
Notifications
You must be signed in to change notification settings - Fork 439
Closed
Labels
Description
I'm using the ActiveModelSerializer
and I have defined a polymorphic relationship in one of my models:
export default Model.extend({
subject: belongsTo({ polymorphic: true }),
});
When I try to serialize a Collection
of that model I would expect plain subject_id
and subject_type
attributes, but instead I get a subject_id
attribute that consists of a JSON object with id
and type
attributes.
I've traced this down to a potential bug in _maybeAddAssociationIds()
of the Serializer
base class. It looks like for serializeIds === "included"
there is a special case for association.isPolymorphic
, but for this.serializeIds === "always"
the same case is missing. Since the rest of the implementation looks similar I would assume that copy-pasting the existing special case in the other branch would solve my problem 🤔