Model / Store Number in Ember-Data

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);
    }
});

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.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Model / Store Number in Ember-Data

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录