I'm running into a tough bug when trying to save a record with the LocalStorage Adapter that has a hasMany relationship (Using Ember CLI). What I'm trying to do is save a product to a bag when a user clicks on a "Add to Bag" button. I'm getting this error in my console:
Uncaught TypeError: Cannot read property 'determineRelationshipType' of undefined
Product Model:
import DS from 'ember-data';
export default DS.Model.extend({
...
bag: DS.belongsTo('bag')
});
Bag Model:
import DS from 'ember-data';
export default DS.Model.extend({
products: DS.hasMany('product', {async: true})
});
Here's the action in the controller:
import Ember from "ember";
export default Ember.ArrayController.extend({
actions: {
addToBag: function(model) {
var bag = this.store.createRecord('bag');
bag.get('products').then(function(products) {
products.pushObject(model);
bag.save();
});
}
}
});
Would anyone have an idea as to what's going wrong? Or another way to approach this? Seems like a similar issue was reported here. Would greatly appreciate any help! Thank you in advance.