2

I'm having a weird issue with meteor when deploying to .meteor.com

Everything works locally but when I deploy my app on meteor.com I get the following error for each of my collections for each routes that I have: collectionName "is not defined". I tried to configure iron-router with waitOn but it didn't help.

My collections definition looks like this(3 server side and one local):

Posts = new Meteor.Collection('posts');
Previews = new Meteor.Collection(null);
betaUsers = new Meteor.Collection('betaUsers');
ipList = new Meteor.Collection('ipList');

//collections/collections.js

My routes look like this:

Router.configure({
  layoutTemplate: 'layout',
  waitOn: function() { [Meteor.subscribe('betaUsers'), Meteor.subscribe('Posts'), Meteor.subscribe('Previews')] }
});

Router.map(function() {
  this.route('jobList', {path: '/', layoutTemplate: 'layout', data: function() { return Posts.find(); }});
  this.route('login', {path: '/login', layoutTemplate: 'layout2'});
  this.route('submitJob', {path: '/submit', layoutTemplate: 'layout2'});
  this.route('previewPost', {path: '/preview', layoutTemplate: 'layout2'});
  this.route('landingPage', {path: '/landing/:_id?', data: function() { return betaUsers.findOne(this.params._id);},  layoutTemplate: 'layoutLp'});
  this.route('thankYouPage', {path: '/thanks/:_id', data: function() { return betaUsers.findOne(this.params._id);}, layoutTemplate: 'layoutLp'});
});

//server/router.js

I use both autopublish and insecure.

Did anybody have the same issue? I used similar structures for collections definition and subscription in previous apps and never had this problem.

I'm still familiarizing myself with Meteor so it's probably a stupid mistake on my side ! Thank you ! I can provide further info.

1 Answers1

1

I simply solved the problem by moving the /collections directory inside the /lib directory. The routes where I provide the data (which are in the /lib directory) were being executed before the collections were defined.

If somebody can explain why my old architecture (separate /lib and /collections ) works locally and not remotely it could still be useful I think. Thanks