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.
I re-investigated this issue and looks like it was addressed in a recent update to ember-localstorage-adapter
. Specifically, the reference to DS.RelationshipChange was removed.
In my bower.json
, I defined my ember-data
version back to 1.0.0-beta.11
and also defined my ember-localstorage-adapter
version to the latest version, 0.5.0
. Here's the relevant info in the bower.json
file:
{
"name": "****",
"dependencies": {
"ember": "1.8.1",
"ember-data": "1.0.0-beta.11",
"ember-localstorage-adapter": "~0.5.0",
}
}
This error is no longer appearing!