I am facing an issue with my application that utilizes Flow Router along with its pub/sub functionality. I have set up a collection and template helpers. The code works fine on the client side.
Template.theCase.helpers({
theCase: function () {
var id = FlowRouter.getParam('id');
var theCase = Cases.findOne({
id: id
});
return theCase;
}
});
and
{{#with theCase}}
{{ id }}
{{/with}}
On the server side, I have the following code:
Meteor.publish('theCase', function (id) {
return Cases.findOne({
id: id
});
});
And in the shared (lib
) code:
FlowRouter.route('/case/:id', {
subscriptions: function (params) {
this.register('theCase', Meteor.subscribe('theCase', params.id));
},
action: function (params, queryParams) {
return BlazeLayout.render('container');
}
});
The issue I am encountering is that the helper function is returning undefined
because it is unable to find items in the collection based on any property other than _id
. I have gone through the official documentation on pub/sub, helpers, and routing but have not been able to find a solution. Can anyone provide any suggestions?