Hans Vn
Hans Vn

Reputation: 844

meteor iron router with data not rendering

I have a meteor project in which I'm trying to render a page with url data, however Meteor is not rendering the right template...

This is my iron router code:

Router.map(function() {
  this.route('profile', {
    path: '/profile/:_id',
    template: 'profile',
    data: function () {
      console.info(this);
      return Meteor.users.findOne({_id: this.params._id});
    }
  }),
  this.route('info'),
  this.route('home', {
    path:'/',
  }),
  ...

and the (simple) template:

<template name="profile">
    {{user}}
</template>

with this helper function:

Template.profile.helpers({
    user: function() { return this; }
)};

I know Meteor goes through the route since the console.info() in the router function dumps an object three(!) times in the console. However I only get to see my homepage and I never get to the profile page.

All information I could find about this came from iron router tutorials or the docs and shows (about) the exact code I have. Has anyone had this problem before? What am I doing wrong?


UPDATE:

I also noticed that when I add an action function to the route, this function never runs...

action : function () {
    console.info("action running!");
    if (this.ready()) {
        this.render();
    }
}

Upvotes: 1

Views: 528

Answers (2)

Hans Vn
Hans Vn

Reputation: 844

Ok seems I made a stupid mistake:

I blocked access to a profile unless it is your own profile. I was testing the access to my page with the wrong user _id.

Upvotes: 0

pahan
pahan

Reputation: 2453

I think there is nothing you have presented here. You just need to publish data from users collection. more about publications

Upvotes: 0

Related Questions