コメント(.../comments/:_id/reply)に返信できるルートを作りたいのですが、コメント関連の投稿が公開できず困っています。
コードは次のとおりです。
出版物
Meteor.publish('commentUser', function(commentId) {
var comment = Comments.findOne(commentId);
return Meteor.users.find({_id: comment && comment.userId});
});
Meteor.publish('commentPost', function(commentId) {
var comment = Comments.findOne(commentId);
return Posts.find({_id: comment && comment.postId});
});
Meteor.publish('singleComment', function(commentId) {
return Comments.find(commentId);
});
ルート
this.route('comment_reply', {
path: '/comments/:_id/reply',
waitOn: function() {
return [
Meteor.subscribe('singleComment', this.params._id),
Meteor.subscribe('commentUser', this.params._id),
Meteor.subscribe('commentPost', this.params._id)
]
},
data: function() {
return {
comment: Comments.findOne(this.params._id)
}
}
});
コメント返信テンプレート
<template name="comment_reply">
<div class="small-12 columns">
{{# with post}}
{{> postItem}}
{{/with}}
</div>
<div class="small-12 columns">
{{#with comment}}
{{> comment}}
{{/with}}
</div>
{{> commentReplySubmit}}
</template>
コメント返信ヘルパー
Template.comment_reply.helpers({
postItem: function() {
return Posts.findOne(this.comment.postId);
}
});
そのルートにアクセスすると、{{#with comment}} は適切にレンダリングされますが、{{#with post}} は表示されません。また、{{#with post}} なしで {{> postItem}} のみをレンダリングしようとすると、html はレンダリングされますが、データはレンダリングされません。
コンソールに次のアラートが表示されます: パラメータが欠落している Route.prototype.resolve を呼び出しました。パラメータに「_id」が見つかりません
前もって感謝します!