0
的特性「的forEach」當我在我的應用程序打「/」,我得到以下類型錯誤:無法讀取未定義的灰燼,數據
Error while loading route: TypeError: Cannot read property 'forEach' of undefined
at Function.Model.reopenClass.eachAttribute (http://localhost:3000/assets/ember-data.js?body=1:4870:32)
at JSONSerializer.extend.normalizeAttributes (http://localhost:3000/assets/ember-data.js?body=1:2906:16)
at JSONSerializer.extend.normalize (http://localhost:3000/assets/ember-data.js?body=1:2827:14)
at superWrapper (http://localhost:3000/assets/ember.js?body=1:1293:16)
at superFunction [as _super] (http://localhost:3000/assets/ember.js?body=1:7724:16)
at RESTSerializer.extend.normalize (http://localhost:3000/assets/ember-data.js?body=1:378:21)
at superWrapper [as normalize] (http://localhost:3000/assets/ember.js?body=1:1293:16)
at null.<anonymous> (http://localhost:3000/assets/ember-data.js?body=1:3179:35)
at Array.map (native)
at JSONSerializer.extend.extractArray (http://localhost:3000/assets/ember-data.js?body=1:3178:37)
相關代碼的堆棧跟蹤是在這裏(在CoffeeScript中):
Plnnr.ApplicationRoute = Ember.Route.extend(
model: ->
@store.find('stage')
)
Plnnr.Stage = DS.Model.extend(
tasks: DS.hasMany("task")
name: DS.attr("string")
description: DS.attr("string")
position: DS.attr("number")
)
Plnnr.ApplicationAdapter = DS.ActiveModelAdapter.extend(
namespace: 'v1'
)
該API使用Rails Serializer進行設置,並且設置斷點表明適配器正在成功檢索數據。
我還設置在灰燼-data.js斷點,在原點,其中故障開始(當.normalize被稱爲在下面的代碼):
var normalizedArray = map.call(payload[prop], function(hash) {
return typeSerializer.normalize(type, hash, prop);
}, this);
此時,類型= DS .Model和hash =序列化的API有效載荷。
我是Ember的新手,不熟悉如何解釋文檔。有誰知道什麼可能是錯的,並且對我如何追蹤這個問題有任何建議?
謝謝!