I have an assistant called 'isActive' and a template called 'create' .. see below
Template.create.isActive = function () { return Meteor.user().profile.isActive; };
When I try to run this code, it returns the following in the console: "Exception in the template helper: TypeError: cannot read the profile property" undefined ".
Basically, I want to output the "isActive" information from the current user profile and return it to the template. Any idea why this is not working?
Update
//startup on server side: Meteor.publish("userData", function() { if (this.userId) { return Meteor.users.find({_id: this.userId}, {fields: {'profile.isActive': 1}}); } else { this.ready(); } }); //startup on client side Meteor.subscribe('userData'); //router this.route('list', { path: 'list', waitOn : function () { return Meteor.subscribe('userData'); }, data : function () { return Meteor.users.findOne({_id: this.params._id}); }, action : function () { if (this.ready()) { this.render(); } } });
source share