App not working once deployed to meteor.com, fine on localhost

So I tried my first little app with Meteor today, and it works fine on localhost, but once I deploy it to meteor.com, I only see the first two headers, and nothing else. I get no errors either, so I’m not sure what to do. Please help me! I’m new to Meteor and the fate of the world hangs on getting this app to work. http://animalcontest.meteor.com

  Animal Vote



  

You decide. Which animals are the best?

click as many times as you like to change the scores

{{#each winnerlist}} {{> winner }} {{/each}} {{#each catslist}} {{> cats }} {{/each}} {{#each dogslist}} {{> dogs }} {{/each}} {{#each elephantslist}} {{> elephants }} {{/each}} {{#each hyenaslist}} {{> hyenas }} {{/each}} {{#each bananaslist}} {{> bananas }} {{/each}}

The current winner is: {{animal}}

current score: {{score}}

cats

current score: {{score}}

dogs

current score: {{score}}

elephants

current score: {{score}}

hyenas

current score: {{score}}

bananas

current score: {{score}}

here’s the javascript
Animals = new Mongo.Collection(‘Animals’);

console.log(“Hello World from Meteor!”);

if(Meteor.isClient){
Template.body.helpers({
‘winnerlist’: function(){

     return Animals.find({}, {sort: {score: -1},limit:1 });
},

 'catslist': function(){
     return Animals.find({animal:"cats"});
 },
 'dogslist': function(){
     return Animals.find({animal:"dogs"});
},

 'elephantslist': function(){	 
     return Animals.find({animal:"elephants"});
},

 'hyenaslist': function(){ 
     return Animals.find({animal:"hyenas"});
},

 'bananaslist': function(){ 
     return Animals.find({animal:"bananas"});
}

});
Template.cats.events({

'click .c-increment': function() {
	
    Animals.update(this._id, {$inc: {score: 5} });
  },
'click .c-decrement': function() {
  
    Animals.update(this._id, {$inc: {score: -5} });
  }

});
Template.dogs.events({

'click .d-increment': function() {
	
    Animals.update(this._id, {$inc: {score: 5} });
  },
'click .d-decrement': function() {
    
    Animals.update(this._id, {$inc: {score: -5} });
  }

});
Template.elephants.events({

'click .e-increment': function() {
	
    Animals.update(this._id, {$inc: {score: 5} });
  },
'click .e-decrement': function() {
   
    Animals.update(this._id, {$inc: {score: -5} });
  }

});
Template.hyenas.events({

'click .h-increment': function() {
	
    Animals.update(this._id, {$inc: {score: 5} });
  },
'click .h-decrement': function() {
    
    Animals.update(this._id, {$inc: {score: -5} });
  }

});
Template.bananas.events({

'click .b-increment': function() {
	
    Animals.update(this._id, {$inc: {score: 5} });
  },
'click .b-decrement': function() {
    
    Animals.update(this._id, {$inc: {score: -5} });
  }

});
}

use “meteor logs yourservice.meteor.com” to check if there’s anything wrong.

I once noticed that the JS load order could be different on server.

Thanks for the feedback! I tried the logs command, but everything appears to working fine- no errors on the logs, but it still isn’t working. I’m stumped.

I’d suspect your Animals DB is empty on server side …

1 Like

Oh, okay! That makes sense. thank you so much. I thought my database with fields in it would deploy along with the app.

Ha, one drawback of Meteor is that it makes newbies automagically assume too many magics :wink:

2 Likes

YES! You were right. My database was empty and now the app is working.
http://animalcontest.meteor.com

You could make your code few times shorter and app easier to develop if you’d iterate through an array of animal objects instead of repeating the same chunks of code for each animal.

Let’s say you’re coming to the ZOO to see some animals. Here’s how you do it:

  1. I come to the ZOO
  2. I watch a tiger
  3. I go back home
  4. I come to the ZOO
  5. I watch an elephant
  6. I go back home
  7. I come to the ZOO
  8. I watch a zebra
  9. I go back home
  10. I come to the ZOO
  11. I watch a monkey
  12. I go back home

Here’s what you could be doing:

  1. I come to the ZOO
  2. I watch animals
  3. I go back home

you are very correct. the code is wet as a hurricane and needs to be DRY.