9.7.1)带有余烬数据(最新的主人),我遇到了一个奇怪的问题。我有一个嵌入的关系:
App.Person = DS.Model.extend({
...
portions: DS.hasMany("App.PersonPortion", { embedded: true}),
...
portionCount: function() {
return this.get('person_portions').get('length')
}.property("person_portions.@each") //This line is the problem. If I remove "person_portions.@each" it will load correctly
})
person 的 JSON 如下所示:
{"age":null,
"created_at":"2012-03-24T09:15:31Z",
"diet_id":5,
"id":1,
"lactating":false,
"name":"cool Name new",
"pregnant":false,
"sex":"F","updated_at":"2012-03-27T15:44:03Z",
"portions":[{"created_at":"2012-04-12T14:54:49Z","crop_id":1,"id":13,"person_id":1,"portion":50,"unit":"grams","updated_at":"2012-04-25T00:41:36Z"},{"created_at":"2012-04-25T00:57:43Z","crop_id":16,"id":20,"person_id":1,"portion":null,"unit":null,"updated_at":"2012-04-26T12:13:48Z"},{"created_at":"2012-04-26T12:13:27Z","crop_id":6,"id":62,"person_id":1,"portion":null,"unit":null,"updated_at":"2012-04-26T12:16:38Z"}]}
但是,当我加载人员时,App.store.find(App.Person, 1)
Ember 仍然尝试从服务器加载“部分”关系。这是来自 Chrome 控制台:
GET http://localhost:3000/person_portions?ids%5B0%5D%5Bcreated_at%5D=2012-04-12T14%3A54%3A49Z&ids%5B0%5D%5Bcrop_id%5D=1&ids%5B0%5D%5Bid%5D=13&ids%5B0%5D%5Bperson_id%5D=1&ids%5B0%5D%5Bportion%5D=50&ids%5B0%5D%5Bunit%5D=grams&ids%5B0%5D%5Bupdated_at%5D=2012-04-25T00%3A41%3A36Z
关于我可能做错了什么或者这是一个错误的任何想法?