我正在尝试本教程http://net.tutsplus.com/tutorials/javascript-ajax/prototyping-with-meteor/
这是我的结构
chat
|_client
| |_chat.html
| |_chat.js
|
|_lib
|_collections.js
在 colletions.js 我正在做
var Rooms = new Meteor.Collection('rooms');
if (Meteor.isServer && Rooms.find().count() == 0) {
var rooms = [
{name: 'Meteor Talk', members: 3, last_activity: '1 minute ago',
messages: [
{author: 'Tom', text: 'Hi there Sacha!'},
{author: 'Sacha', text: 'Hey Tom, how are you?'},
{author: 'Tom', text: 'Good thanks!'},
]},
{name: 'Meteor Development', members: 2, last_activity: '5 minutes ago'},
{name: 'Meteor Core', members: 0, last_activity: '3 days ago'}
]
_.each(rooms, function(room) {
Rooms.insert(room);
});
}
在 chat.js 中
Template.rooms.helpers({
rooms: function() { return Rooms.find(); }
});
我收到错误消息Rooms is not defined
,如果我调试,我看到文件夹 lib/collections.js 正在加载,但没有被调用。
我的代码或配置中是否缺少某些内容?
谢谢