I'm using Ember's RESTAdapter and have a pretty standard polymorphic relationship:
// models/order.js
import DS from 'ember-date';
export default DS.Model.extend({
transferableItem: DS.belongsTo('transferable-item', { polymorphic: true })
});
// models/transferable-item.js
import DS from 'ember-date';
export default DS.Model.extend({
order: DS.belongsTo('order')
});
// models/ticket.js
import TransferableItem from './transferable-item';
export default TransferableItem.extend();
My JSON looks like this:
{
"orders": [{
"id": 111,
"transferableItem": 999
"transferableItemType": "Ticket"
}],
"tickets": [{
"id": 999
}]
}
Looking in Ember Inspector, both Orders and Tickets properly load. However, the link between the two of them is broken. I get this error:
You looked up the 'transferableItem' relationship on a 'order' with id 999 but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (
DS.belongsTo({ async: true }))
According to Ember Inspector, there are no transferable-items loaded, so in a way, this error makes sense. However, since this is a polymorphic relationship, shouldn't it just try to use the associated Ticket, which is in fact loaded?
Aucun commentaire:
Enregistrer un commentaire