2015-02-05 44 views
1

传达我有一个看起来像这样path: '/speakers/singleDetails/:_id'像这样路线:_id与模式_id场流星

speakerId: { 
    type: String, 
    autoValue: function(){ 
     return this.params._id; 
    } 
} 

与现场架构的路径我想要的speakerId领域的autoValue返回/:_id那追加到path,但我正在逐渐Uncaught TypeError: Cannot read property '_id' of undefined

UPDATE

我现在设置我idPath在我的路由器和get它在采集模式

onBeforeAction: function(){ 
    console.log(this.params._id); 
    Session.set('idPath', this.params._id); 
    this.next(); 
} 

speakerId: { 
    type: String, 
    autoValue: function(){ 
     return Session.get('idPath'); 
    } 
} 

但现在我得到这个错误:Exception in delivering result of invoking '/singleDetails/insert': Error: Internal server error [500]

回答

1

为什么没有与_id?

会话喜欢这个。在路线上

Session.set('idPath',this.params._id); 

和架构上。

speakerId: { 
    type: String, 
    autoValue: function(){ 
     if (this.isInsert) { 
     return Session.get('idPath'); 
     } 
    } 
} 

有关autoValue方法的更多信息,请登录Aldeed/Meteor-collections2

+0

你能看看我更新的帖子吗? – redress 2015-02-05 18:14:19

+0

'错误:内部服务器错误[500]'我可以在控制台上看到日志吗?服务器控制台 – Ethaan 2015-02-05 18:20:06

+0

检查答案更新,我们在'speakerId'字段中加入'if(this.isInsert)' – Ethaan 2015-02-05 18:24:14