On my apps homepage all the posts show up, and the collection Posts.find().count() is accurate. But when I go to the individual post page Posts.find().count() gives me 0. I’m pretty sure it has to do with my routing and subscription through the routing. What exactly is going on?
Here is my routing code
Router.route('/:postsLimit?', {
name: 'postsList',
waitOn: function() {
var limit = parseInt(this.params.postsLimit) || 5;
return Meteor.subscribe('posts', {sort: {submitted: -1}, limit: limit});
},
data: function() {
var limit = parseInt(this.params.postsLimit) || 5;
Session.set('pageView','list');
return {
posts: Posts.find({}, {sort: {submitted: -1}, limit: limit})
};
}
});
Router.map(function() {
this.route('singlePost',{
path:'profile/:userName/post/:_id',
waitOn: function() {
return Meteor.subscribe('comments', this.params._id);},
data:function(){
Session.set('pageView','single');
return Posts.findOne(this.params._id);}
});
this.route('editPost',{
path:'/:userName/post/:_id/edit',
data:function(){
Session.set('pageView','single');
return Posts.findOne(this.params._id);
}
});
this.route('profile',{
path:'profile/:userName',
data:function(){
return Profiles.findOne({userName: this.params.userName});
}
});
});