Reputation: 31
In a meteor project using iron-router, a pathFor in my template can't find a named route. I think I've adhered to the syntax in the guides.
Here's the spacebars code:
<a href="{{pathFor 'tag.show' _id=this._id }}" class="tag" id="{{title}}">{{title}}</a>
And here's the iron-router code:
Router.route('/tags/:_id', function() {
this.layout('layout');
this.render('tags');
this.render('tagDetail', {
to: 'topDrawer',
data: function() {
return Tags.findOne({
_id: this.params._id
});
}
});
}, {
name: 'tag.show'
});
What am I doing wrong?
EDIT: The exact error in my console is
pathFor couldn't find a route named "tag.show"
EDIT 2: For kicks, I tried retrieving another simpler route by name:
Router.route('/', function() {
this.render('home');
}, {
name: 'home'
});
Router.go('post.show');
And I get an 'undefined' error. I haven't been able to solve this problem.
Upvotes: 3
Views: 1583
Reputation: 773
I think you have your declaration backwards, try:
Router.route('tag.show', function() {
this.layout('layout');
this.render('tags');
this.render('tagDetail', {
to: 'topDrawer',
data: function() {
return Tags.findOne({
_id: this.params._id
});
}
});
}, {
path: '/tags/:_id'
})
By the way this may be caused by a change in the iron router api. The version I'm using is 0.9.4 and this is how I declare routes in that version:
this.route('home', {path: '/'});
Then elsewhere I define a custom controller:
HomeController = RouteController.extend({
// nothing yet
});
Upvotes: 0