As I embarked on building my first app with Meteor, everything seemed to be going smoothly until I encountered an issue where a collection was no longer displaying in a template.
Here is the code snippet:
App.js
Tasks = new Mongo.Collection("tasks");
if (Meteor.isServer) {
Meteor.publish("tasks", function () {
return Tasks.find();
});
}
if (Meteor.isClient) {
Meteor.subscribe("tasks");
Template.body.helpers({
tasks: function () {
return Tasks.find({}, {sort: {createdAt: -1}});
}
});
}
App.html
<template name="home">
<h3>Open Tasks</h3>
<ul>
{{#each tasks}}
{{> displayTasks}}
{{/each}}
</ul>
</template>
<template name="displayTasks">
<li>{{text}}</li>
</template>
Routes.js
Router.route("/", function () {
this.render("Home");
});
I've consulted resources like and MeteorJS template not showing data, not appearing to ensure that my implementation is correct. Despite changing names and attempting to display tasks on different templates, the issue persists. Data exists in MongoDB, and manual insertion using the Mongo console verifies that the `text` fields are populated.
What steps should I take next to troubleshoot this problem? Backtracing has been fruitless, and recreating the app from scratch is a last resort that I hope to avoid.
NOTE: Iron Router is being utilized in this application.