1
votes

I'm having some trouble after upgrading to the most recent version of ember-data (1.0 beta 5...I was previously v 14). The error I'm getting is "Error while loading route: TypeError: Cannot set property 'store' of undefined". I'm not setting the store at this point. The error occurs right after the "model" function is called in the route. Any pointers are appreciated.

CallMonitor.ContactPoint = DS.Model.extend({
    "status": DS.attr('string'),
    "contact": DS.belongsTo('contact')
});
CallMonitor.Contact = DS.Model.extend({
    "type": DS.attr('string'),
    "status": DS.attr('string'),
    "message": DS.attr('string'),
    "creator": DS.attr('string'),
    "spid": DS.attr('string'),
    "added": DS.attr('date'),
    "contactPoints": DS.hasMany('contactPoint')
});


CallMonitor.ApplicationAdapter = DS.RESTAdapter.extend({namespace: 'api'});

CallMonitor.ContactsRoute = Ember.Route.extend({
    model: function(){
        return  this.store.find('contact');
    },
    setupController: function(controller, contacts) 
        controller.set('contact', contacts);
    }
});
2

2 Answers

1
votes

It looks like this is a documentation issue with Ember or somesuch. On this page... http://emberjs.com/guides/models/defining-models/ you can see that the "hasmany" attribute has a plural key ("comments" like mine, "contactPoints") Apparently, this isn't right anymore. I made this key singular "contactPoint" and it worked fine.

1
votes

For additional changes check the Ember Data transition for 1.0

https://github.com/emberjs/data/blob/master/TRANSITION.md