我有一个应用程序需要在其中一个路径中使用两个模型。
这里我使用 RSVP.hash 将两个promises捆绑成一个并将它们返回给setupController。不知何故,其中一条记录未被正确检索,并且不包含任何数据(也未请求服务器)。所以解决了promise hash之后的记录状态仍然是 root.empty 。
我目前使用从服务器调用 record.reload()的变通方法,这会触发重新提取,如下所示:
dfrm<-data.frame(id=letters[1:3],x=c(-1/9/1e15,-1/9/1e14,-1/9/1e14),
y=c(1/9/1e15,1/9/1e14,1/9/1e14))
library(dplyr)
dfrm %>%
# select only numeric columns
select(which(sapply(., is.numeric))) %>%
# remove rows
slice(which(!duplicated(round(., -8)))) %>%
# right join the result with original dataset (get back unselected non-numeric columns)
right_join(dfrm, .)
筹码:
model: function(param){
return Ember.RSVP.hash({
activities: this.store.find('activity', {'component_id': param.component_id}),
component: this.store.find('component', param.component_id)
}).then(function(models){
//move component manually from DS.RootState.empty to loaded.saved
models.component.transitionTo('loaded.saved');
//force reload returns a promise.
return models.component.reload().then(function(component){
return {component: component, activities: models.activities};
});
});
}
编辑:我已经开始调试问题,并意识到记录的isEmpty属性设置为false,因此查找不会到达服务器。
由于我认为这种解决方法对我来说不好看,我觉得我一定忘记了什么,所以我的问题是:
如果您需要更多信息,我很乐意提供。
答案 0 :(得分:0)
在你的路线model
中持有两种不同类型的模型对我来说似乎很混乱,我建议只加载路线所属的模型,然后在{{1}中加载后续模型并在控制器上设置它们}。
setupController