I’m getting an assertion error about adding records of polymorphic type that don’t inherit from the defined type:
Uncaught Error: Assertion Failed: You cannot add a record of type 'recipe' to the 'build-item.item' relationship (only 'item' allowed)
Using 2.3.0
, it’s coming from here. I’m not really sure why ED cares about this at all (especially with JSONApiAdapter
) but okay I get it I need to change something.
The problem is I have one model that must be able to be polymorphic for two different models. Take the following:
Build = DS.Model.extend({
builder: belongsTo('builder')
});
BuildItem = DS.Model.extend({
build: DS.belongsTo('build'),
item: DS.belongsTo('item')
});
Builder = DS.Model.extend({});
Item = DS.Model.extend();
// Ingredient is only an Item... so this works fine
Ingredient = Item.extend();
// Product is only a Builder... so this works fine
Product = Builder.extend();
// Recipe is both a Builder and an Item...
Recipe = Builder.extend();
How can I define Recipe as both an Item and a Builder so that ED doesn’t stop in it’s tracks for some reason?
Also, it doesn’t make sense that ember data would hard code privately the check without bringing this up to the model level.
Side Note: Ember data has a tagged release version 2.3.3
which has removed this check from the production build but installing via ember install ember-data@2.3.3
still includes a build a where the assertion error is still there and raising… not sure what is going on there.