I'm encountering some difficulties when trying to create a route that allows me to respond to comments (.../comments/:_id/reply) and publish the related post. Below is the code snippet:
Publications
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);
});
Route
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)
}
}
});
Comment Reply Template
<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>
Comment Reply Helper
Template.comment_reply.helpers({
postItem: function() {
return Posts.findOne(this.comment.postId);
}
});
While the {{#with comment}} displays correctly, the {{#with post}} does not appear when I access the route. Additionally, if I try to render only {{> postItem}}, it displays the HTML without any data. The console outputs an alert stating: You called Route.prototype.resolve with a missing parameter. "_id" not found in params
Thank you for your assistance!