gpt4 book ai didi

ember.js - Ember 金丝雀 “Uncaught Error: Assertion Failed: You can only add a '里程碑'对此关系的记录”

转载 作者:行者123 更新时间:2023-12-02 06:04:21 27 4
gpt4 key购买 nike

我有以下 Controller :

Filters.FiltersController = Ember.ArrayController.extend({
needs: ["milestones"],
selectedMilestone: null,
selectedMilestoneChange: function() {
if(!this.get('filterTypeSelected') || !this.get('selectedMilestone')) {
return;
}
var filter = this.store.createRecord('filter', {
type: 'milestone',
value: this.get('selectedMilestone').get("id"),
negate: this.get('filterTypeSelected').negate,
milestone: this.store.find('milestone', this.get("selectedMilestone").get("id"))
});
filter.save();
this.resetFilterCreator();
}.observes('selectedMilestone')
});

每当 View 更改 selectedMilestone属性时,它都会创建一个新的 filter实例并将其保存。

这一直有效,直到我升级到Ember-canary以使用query-parameters-new功能。升级后,每当创建过滤器记录时,都会引发以下错误:

Uncaught Error: Assertion Failed: You can only add a 'milestone' record to this relationship



错误源于
milestone: this.store.find('milestone', this.get("selectedMilestone").get("id"))

型号是:
Filters.Filter = DS.Model.extend({
type: DS.attr('string'),
value: DS.attr('string'),
milestone: DS.belongsTo('milestone'),
negate: DS.attr('boolean')
});

我该如何工作?

最佳答案

问题是(显然是在新的Ember版本中),从this.store.find(...)返回是一个 promise ,因此不是instanceof Milestone

相反,您可以解决 promise ,也可以使用this.store.getById('model', 'id')。但是,这需要已检索模型(在我的情况下为onLoad)。

关于ember.js - Ember 金丝雀 “Uncaught Error: Assertion Failed: You can only add a '里程碑'对此关系的记录”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22128053/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com