Create user profile page


#1

Hey everyone, I’m a newbie when it comes to Meteor and programming in general. I’m trying to create a page for users so that when they are logged in they can see the content they’ve uploaded onto the site, kind of like a profile page. I can’t seem to get the page to render. I’ve searched all over and tried stack overflow. Any ideas of where I’m going wrong?

from my publication.js file

Meteor.publish('myTickets', function() { var currentUserId = this.userId; return Tickets.find({ createdBy: currentUserId }) });

from the router.js

Router.route('/users/:_id', { name: 'userPage', waitOn: function() { return Meteor.subscribe('myTickets'); }, data: function() { return Tickets.find({ userId: Meteor.userId() }) } });

userpage.js

 Template.userPage.helpers({
  tickets: function() {
  var currentUserId = Meteor.userId();
  return Tickets.find({
  createdBy: currentUserId
}, 
{sort: {
createdAt: -1 }
});
  }
}); 

View
<template name="userPage">
<div class="tickets">
{{#if ownTicket}}

{{>myTickets}}

{{/if}}

{{#if nextPath}}

<a class="load-more" href="{{nextPath}}">Load More</a>

{{else}} {{#unless ready}} {{>spinner}} {{/unless}} {{/if}}

  </div>

</template>

not sure why my indention’s all messed up.


#2

Hi @diiv182,

In case you haven’t solved this by now, it seems like your helper is using the wrong variable for returning the tickets.
In the publication function you use the “createdBy” parameter:

return Tickets.find({
     createdBy: currentUserId
  })

But your helper is using “userId”:

return Tickets.find({
    userId: Meteor.userId()
    })

If you use “createdBy” in your helper, it should solve the problem.
I hope it’s still usefule by now.