Unable to read property 'determinRelationshipType' when trying to save () Model with hasMany Relationship


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) {

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 started a project using the emberfire adapter and ran into the same issue.

Without going to deep into this, it looks like ember-data beta.10 deprecated a feature that was necessary for hasMany to work. (Further reading https://github.com/firebase/emberfire/issues/123)

Downgrading to ember-data beta.8 fixed the issue for me.

This is necessary until the adapters (emberfire and/or localstorage) can be updated.

In my ember-cli project I did:

rm -rf vendor/ember-data/ bower cache clean ember-data Edit files vendor/emberfire/bower.json and vendor/emberfire/.bower.json to say "ember-data": "1.0.0-beta.8".

bower install