0

Theres is a Meteor Windows Release bug?

When I try this, works:

//Main File
Persons = {}
Persons.person = {name : "Roger", age : 30}

//Another file
console.log(Persons.person);

But when I call in another JS, like the code bellow, with a "console.log("Persons")" dont works:

PersonsCollection = new Mongo.Collection("persons");
Meteor.subscribe("allPersons");


// THIS CODE
console.log(Persons);


if (Meteor.isServer) {
    PersonsCollection.allow({
        insert : function () {
            if(Roles.userIsInRole(Meteor.userId(), ['admin'])){
                return true;
            } else{
                return false;
            }
        },
    update : function () {
        if(Roles.userIsInRole(Meteor.userId(), ['admin'])){
            return true;
        } else{
            return false;
        }
    },
    remove : function () {
        if(Roles.userIsInRole(Meteor.userId(), ['admin'])){
            return true;
        } else{
            return false;
        }
    }
});
}

The structure:

models/personsCollection.js //Bug here
models/test1.js //I have created the global var here
models/test2.js //I called here
  • Duplicate of http://stackoverflow.com/questions/26836390/how-can-i-access-constants-in-the-lib-constants-js-file-in-meteor/ – Kyll Mar 25 '15 at 20:49
  • Thanks. Is duplicated but do not have the answer I need. I tried with constants too. And returns Reference Error. – MeteoritoBr Mar 25 '15 at 20:58
  • If it hasn't got the answer to your question, I'm afraid I can't currently help you more. You could have a load order or maybe scope issue, but that's treated in the question I gave you, so that's not it. Try providing more code or file names to let us understand better. – Kyll Mar 25 '15 at 21:05
  • I tried the example and worked. But still dont working. I think its a bug. I have updated the question. – MeteoritoBr Mar 25 '15 at 22:01
  • Really looks like some load order mess. Try to check [the doc](http://docs.meteor.com/#/full/structuringyourapp), at the `File Load Order` part. You could also provide us with the paths of each file and the file names. – Kyll Mar 25 '15 at 22:44
  • I updated. The structure is in the bottom. So, I have created a past name "a_globalVars" with the test1.js inside and worked. This is the better way? @Kyll – MeteoritoBr Mar 25 '15 at 23:57
  • I depict various ways to declare global variables in my answer on the other question. Please check it to try the solutions that work best for you. My personal favourite is the package way. – Kyll Mar 26 '15 at 08:04

0 Answers0