Search code examples
meteorpublishiron-router

Trying to publish users in Meteor


I'm quite new in Meteor and I got an issue: I added some information to users and I'd like to be able to see it in a view.
So I create my users, here is my event:

Accounts.createUser({
    username: username,
    email: email,
    password: password,
    firstname:firstname,
    lastname:lastname,
    chief:chief
},
function(error){
    if(error){
        alert(error.reason)
    }else{
        Router.go('home');
    }
});
Accounts.onCreateUser(function(options,user){
    user.firstname = options.firstname;
    user.lastname = options.lastname;
    user.chief = options.chief;
    return user;
});

then I publish my collection to get access on my client side of the app:

Meteor.publish("personaldata", function () {
    return Meteor.users.find({_id: this.userId});
});

And without doing anything else I got an issue on my app: there is no error message on my command prompt, but when I open my app I got an Ironn:Router message. Here is the message:


'organize your application'

Router.route('/', function () {
    this.render('Home', {
        data: function () {
            return Items.findOne({_id: this.params._id});
        }
    });
});

Yes the whole part is the message. I tried to subscribe to the collection in 'home' to settle the issue but it doesn't work, the same message is displayed.

Does someone know why this message is displayed ? How can I have access to those data? Isn't it the proper way?

Hope you guys can figure out what the problem is, thanks.


Solution

  • Found the problem...

    As I'm stupid I put my publish in the lib directory, so this was on both the server and the client side... Meteor didn't know what to do with it on the client side.