0
votes

I've recently been trying to work through the Discover Meteor book in an attempt to learn Meteor. In this part we make a 'discuss' button that will route to a page displaying only one component of a list.

A couple of people on the official git site have been talking about how the 'discuss' button is not rendering {{postPagePath this}} even when following the instructions in the book.

I'm wondering if Meteor may have changed its routing format since this book was written.

Here is the git page: https://github.com/SachaG/Microscope/commit/d0e035e2b175f755b80f3c4201cd5aae5f6885d2

2

2 Answers

0
votes

If you've managed to get to that point without any issues before that, then theres no changes that would stop you from being able to complete that section.

Could you share your code of Templates HTML and also your Router js code?

0
votes

Wasn't quite sure which html so I put 2.

application/layout.html

<template name="layout">
  <div class="container">
    {{> header}}
    <div id="main">
      {{> yield}}
    </div>
  </div>
</template>

header.html

<template name="header">
  <nav class="navbar navbar-default" role="navigation">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed"     data-toggle="collapse" data-target="#navigation">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="{{pathFor     'postsList'}}">Microscope</a>
    </div>
    <div class="collapse navbar-collapse" id="navigation">
      <ul class="nav navbar-nav">
        {{#if currentUser}}<li><a href="{{pathFor 'postSubmit'}}">Submit     Post</a></li>{{/if}}
      </ul>
      <ul class="nav navbar-nav navbar-right">
        {{> loginButtons}}
      </ul>
    </div>
  </nav>
</template>

router.js

Router.configure({
  layoutTemplate: 'layout',
  loadingTemplate: 'loading',
  notFoundTemplate: 'notFound',
  waitOn: function() { return Meteor.subscribe('posts'); }
});

Router.route('/', {name: 'postsList'});

Router.route('/posts/:_id', {
  name: 'postPage',
  data: function() { return Posts.findOne(this.params._id); }
});

Router.route('/posts/:_id/edit', {
  name: 'postEdit',
  data: function() { return Posts.findOne(this.params._id); }
});

Router.route('/submit', {name: 'postSubmit'});

var requireLogin = function() {
  if (! Meteor.user()) {
    if (Meteor.loggingIn()) {
    this.render(this.loadingTemplate);
     } else {
    this.render('accessDenied');
  }
  } else {
    this.next();
  }
}

Router.onBeforeAction('dataNotFound', {only: 'postPage'});
Router.onBeforeAction(requireLogin, {only: 'postSubmit'});