Ember Data:加载数据散列...但没有提供主键'undefined' [英] Ember Data: A data hash was loaded ... but no primary key 'undefined' was provided

查看:63
本文介绍了Ember Data:加载数据散列...但没有提供主键'undefined'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Ember Data加载模型。获取模型的AJAX调用似乎是成功的,但我得到以下

I'm trying to use Ember Data to load a model. The AJAX call to fetch the model seems to be successful but I get the following


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

在ember-data.js:1128中,似乎对primaryKey进行引用未定义,而不是默认为'id',当模型不不要指定一个primaryKey。但是我也试图用primaryKey来显示没有效果。

In ember-data.js:1128 it seems to be deferencing undefined for the primaryKey and not defaulting to 'id' when a model doesn't specify a primaryKey. But I've also tried being explicit with the primaryKey to no effect.

为了完整,这里是我的模型:

For completeness, here is my model:


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)

任何想法?

推荐答案

我通过升级到最新的边缘Ember Data(我以前使用两个项目的当前发行版本)来修复这一点:0.9.8.1用于ember。 js和ember-data github站点上的四个月前的ember-data-latest.js)。我仍然使用相同的ember.js发行版,但升级Ember Data似乎已经解决了这一点。

I "fixed" this by upgrading to the latest edge Ember Data (I was previously using both of the current distributions from both projects: 0.9.8.1 for ember.js and the four month old ember-data-latest.js on the ember-data github site). I'm still using the same ember.js distribution but upgrading Ember Data seems to have resolved this.

这篇关于Ember Data:加载数据散列...但没有提供主键'undefined'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆