meteoriron-router

Route returning blank page [METEOR]


I am trying to create a route for a user profile page, but when I visit the route it shows up as a completely blank page and with no errors in the terminal. Nothing whatsoever is shown, including static HTML. Here's the code:

routes.js

Router.route('/user/:_id', function () {
  this.render('user');
}, {
  name: 'user',
  data: function(){
    return Users.findOne({_id: this.params._id})
  }
});

user.html

<template name="user">
    <p>hello</p>
</template>

At the moment, I am using the default user accounts package and have not added any publication or subscription code.


Solution

  • Are you sure Users is an existing collection?

    At the moment, I am using the default user accounts package and have not added any publication or subscription code.

    In that case, with autopublish enabled, your problem is probably solved by changing

    data: function(){
      return Users.findOne({_id: this.params._id})
    }
    

    into:

    data: function(){
      return Meteor.users.findOne({_id: this.params._id})
    }
    

    although it's strange this doesn't throw an error in your console...