2014-01-14 45 views
1

升級到最新版本的ember-data(1.0 beta 5 ...我之前爲v 14)後遇到一些麻煩。我得到的錯誤是「加載路徑時出錯:TypeError:無法設置未定義的屬性」商店「。在這一點上我沒有設置商店。在路由中調用「模型」函數後,錯誤就會發生。任何指針讚賞。Ember-Data中的模型/商店問題

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

回答

1

看起來這是Ember或somesuch的文檔問題。在這個頁面上... http://emberjs.com/guides/models/defining-models/你可以看到「hasmany」屬性有一個複數鍵(像我的「評論」,「contactPoints」)顯然,這是不對的了。我做了這個關鍵單數「contactPoint」,它工作正常。