Ember.js 使用belongsTo关系推送存储区中的记录

Ember.js 使用belongsTo关系推送存储区中的记录,ember.js,ember-data,Ember.js,Ember Data,我想把新的对话推到商店里。我正在使用: this.store.push('conversation', received_message.conversation); 在这一行中,received_消息是由推送器事件从服务器返回的JSON数据。我遇到的问题是,对话中有一个客户是由与我的客户模型的belongsTo关系定义的。当我想要推送时,它告诉我Ember Data需要一个字符串或数字作为“customer”,但找到了一个嵌入的关系 我已经用customer always embedded定

我想把新的对话推到商店里。我正在使用:

this.store.push('conversation', received_message.conversation);
在这一行中,received_消息是由推送器事件从服务器返回的JSON数据。我遇到的问题是,对话中有一个客户是由与我的客户模型的belongsTo关系定义的。当我想要推送时,它告诉我Ember Data需要一个字符串或数字作为“customer”,但找到了一个嵌入的关系


我已经用customer always embedded定义了DS.EmbeddedRecordsMixin。我该怎么办?现在,customer作为一个JSON对象返回。

好的,伙计们,我就是这么做的。我讨厌回答我自己的问题,因为这意味着我在发帖前没有搜索到足够的信息,但现在我们到了

我所做的是在返回的JSON中独立地加载所有模型。我在jbuilder中将客户和子用户设置为空值。然后,我使用以下三行分别将客户、子用户和对话推入商店:

this.store.push('customer', received_message.conversation.customer);
this.store.push('subuser', received_message.conversation.subuser);
this.store.push('conversation', received_message.conversation);

然后,我通过使用检索模型来手动建立模型之间的关系。查找并为客户和子用户分配。然后。工作很有魅力。

你能分享你的对话模式和连载器吗?