Search code examples
meteoriron-routerpublish-subscribe

Publish/subscribe not working - how to debug?


I am trying to switch my app from autopublish to publish/subsribe. After trying to set publish/subscribe up or my first collection, none of my items from the collection are being displayed anymore, and I am at a loss at what might be going wrong.

Can someone spot a mistake in my code below or give any hints as to how to debug this type of problem?

client/routes.js

Router.route('/slug', {
  name: 'route.name',
  title: 'My Page',
  template: 'TemplateName',
  subscriptions: function() {
    this.subscribe('myPublication');
  },
  action: function() {
    this.render();
  }
});

server/lib/collectionLib.js

...
Meteor.publish('myPublication', function() {
  return MyCollection.find();
});

client/myCollection/view/mycollection-list.html

...
{{#each myCollection}}
    ...
{{/each}}
...

Solution

  • I was missing the exposure of the collection to the template. See answer provided here: https://forums.meteor.com/t/publish-subscribe-not-working-how-to-debug/13127/6?u=codejak