I set up my router so that if someone types in sitename.com/:username, it goes directly to that users page. But for some reason, when I attempt to do this I sometimes get redirected to my home page and get this error in the console.
Sorry, couldn't find the main yield. Did you define it in one of the rendered templates like this: {{yield}}?
It's even more strange because I would say 60% of the time it loads fine and there are no issues. Does anyone familiar with Meteor, Handlebars, and the Iron-Router package know about this or can help?
If you need more code let me know.
Here is the routing. I added the wait() call at the end to see if that would help. It seems to have helped a bit but the error still occurs.
this.route('userPosts', {
path: '/:username',
layoutTemplate: 'insideLayout',
template: 'userPosts',
yieldTemplates: {
'insideNavigationList': {to: 'list'},
'brandContainer': {to: 'brand'},
'postsPageOptions': {to: 'pageOptions'}
},
waitOn: function () {
return [Meteor.subscribe('userData'), Meteor.subscribe('selectedUser', this.params.username), Meteor.subscribe('posts', this.params.username)];
},
data: function () {
return Meteor.users.findOne({username: this.params.username}) && Session.set('selectedUserId', Meteor.users.findOne({username: this.params.username})._id)
},
before: function () {
if (!Meteor.user()) {
this.redirect('/login')
}
this.subscribe('selectedUser', this.params.username).wait();
this.ready();
}
});