Reputation: 16240
Currently I am using the accounts packages supplied by Meteor to allow people to sign up for the site I am working on. I want to allow users to have a bio page, whenever I am logged into a particular person a side bar navigation appears with a lot of links one of which says "Bio". I want bio to redirect me from the home page to MY bio page i.e:
localhost:3000/ -> localhost:3000/bio/uSerId23453423434
Currently write now I am using Iron-Router to do this:
...
<li><a href="{{pathFor 'bio'}}">Bio</a></li>
...
And in my Router I have:
Router.map(function() {
...
this.route('bio',
{path: '/bio/:_id',
data: function () { return {_id: Meteor.userId()} }
});
...
But when I click on the link I am not redirected anywhere. Any ideas as to what I am doing wrong?
Upvotes: 0
Views: 248
Reputation: 1049
you don't need the parameter _id in your path since you are already using Meteor.userId(). Iron-router won't render if it can't find the _id parameter in the template. Removing it will fix your issue:
Router.map(function() {
...
this.route('bio',
{path: '/bio',
data: function () { return {_id: Meteor.userId()} }
});
...
If you want to keep the path with the _id you should render using {{#with}} to set the data context, for your {{pathFor 'bio'}}
You can view more information at:
Upvotes: 1