【问题标题】:Collections become undefined on Meteor deploy集合在 Meteor 部署时变得未定义
【发布时间】:2014-12-01 08:44:55
【问题描述】:

我在部署到 .meteor.com 时遇到了一个奇怪的流星问题

一切都在本地运行但是当我在meteor.com上部署我的应用程序时对于我拥有的每条路线的每个集合,我都会收到以下错误:collectionName "is没有定义的”。 我尝试使用waitOn 配置 Iron-router,但没有帮助。

我的集合定义如下(3 个服务器端和一个本地):

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

//collections/collections.js

我的路线如下所示:

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

我同时使用自动发布和不安全。

有人遇到同样的问题吗?我在以前的应用程序中使用类似的结构来定义集合和订阅,但从未遇到过这个问题。

我还在熟悉 Meteor,所以这对我来说可能是一个愚蠢的错误!谢谢 !我可以提供更多信息。

【问题讨论】:

    标签: collections meteor iron-router deploying


    【解决方案1】:

    我只是通过将/collections 目录移动到/lib 目录中来解决问题。我提供数据的路由(位于/lib 目录中)在定义集合之前执行。

    如果有人能解释为什么我的旧架构(单独的 /lib/collections )在本地而不是远程工作,我认为它仍然有用。谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2013-07-10
      • 1970-01-01
      • 2015-07-16
      • 2015-03-08
      • 1970-01-01
      • 2018-11-05
      相关资源
      最近更新 更多