2012-06-03 28 views
3

我試圖使用Ember Data加載模型。 AJAX調用,以獲取模型似乎是成功的,但我得到以下Ember Data:數據散列已加載...但未提供主鍵「未定義」

 
Uncaught Error: assertion failed: A data hash was loaded for a model of type App.Account but no primary key 'undefined' was provided. 

在燼-data.js:1128它似乎deferencing未定義的PrimaryKey的,而不是默認爲「身份證」,當一個模型不指定primaryKey。但我也試圖明確primaryKey沒有效果。

爲了完整起見,這裏是我的模型:

 
App.Account = DS.Model.extend({ 
    portfolio_id: DS.attr('integer'), 
    title: DS.attr('string'), 
    user_id: DS.attr('integer'), 
    url: 'investment_account' 
}); 

,我加載帳戶具有如下:

 
App.store.find(App.Account, account_id) 

任何想法?

+0

我使用-latest這兩個燼和燼數據都遇到了同樣的問題。 –

回答

4

我通過升級到最新的Ember Data來修復這個問題(我以前使用兩個項目的當前發行版:0.9.8.1 for ember.js和四個月大的ember-data-latest.js在ember-data github網站上)。我仍然使用相同的ember.js發行版,但升級Ember Data似乎解決了這個問題。