title: Exception while simulating the effect of invoking 'insertPlayerData' ReferenceError: currentUserId is not defined
body: <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>PlayerList = new Mongo.Collection('players');
  UerAccounts = new Mongo.Collection('user');
  if(Meteor.isClient){
  Template.leaderboard.helpers({
       'player':function(){
           var currentUserId = Meteor.userId();
    return PlayerList.find({createdBy: currentUserId},{sort: {score: -1,name: 1}})
        },
       'selectedClass':function(){
    var playerId = this._id;
    var selectedPlayer = Session.get('selectedPlayer');
    if(playerId == selectedPlayer){
    return "selected"
          }
        },
        'showSelectedPlayer':function(){
           var selectedPlayer  = Session.get('selectedPlayer');
           return PlayerList.findOne(selectedPlayer)
        }        
  });
  Template.leaderboard.events({
       'click .player': function(){
    var playerId = this._id;
           Session.set('selectedPlayer', playerId);
        },
        'click .increment':function(){
           var selectedPlayer = Session.get('selectedPlayer');
           PlayerList.update(selectedPlayer,{$inc:{score: 5}});
        },
        'click .decrement':function(){
           var selectedPlayer = Session.get('selectedPlayer');
           PlayerList.update(selectedPlayer,{$inc:{score: -5}});
        },
        'click .remove':function(){
           var selectedPlayer = Session.get('selectedPlayer');
           PlayerList.remove(selectedPlayer);
        }  
  });
  Template.addPlayerForm.events({
        'submit form':function(event){
           event.preventDefault();
           var playerNameVar = event.target.playerName.value;
           Meteor.call('insertPlayerData');
        } 
  });
        Meteor.subscribe('thePlayers');
        Meteor.methods({
   'insertPlayerData': function(){
      var currentUerId = Meteor.userId();
      PlayerList({
    name:"David",
    score:0,
    createdBy:currentUserId
    });
   }
  });
  }
  if(Meteor.isServer){
       Meteor.publish('thePlayers',function(){
         var currentUserId = this.userId;
         return PlayerList.find({createdBy: currentUserId})
  });
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;head&gt;
      &lt;title&gt;Leaderboard&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Leaderboard&lt;/h1&gt;
      {{&gt; leaderboard}}
      {{&gt; loginButtons}}
  &lt;/body&gt;
  &lt;template name="leaderboard"&gt;
     
       &lt;ul&gt;
           {{#each player}}
           &lt;li class="player {{selectedClass}}"&gt;{{name}}: {{score}}&lt;/li&gt;
           {{/each}}
       &lt;/ul&gt;
       &lt;input type="button" class = "increment" value ="give five points"&gt;
       &lt;input type="button" class = "decrement" value ="take five points"&gt;
       &lt;input type="button" class = "remove" value="remove player"&gt;
     {{#if showSelectedPlayer}}
       &lt;li&gt;slected Player: {{showSelectedPlayer.name}}&lt;/li&gt;
     {{/if}}
     {{&gt; addPlayerForm}}
       
  &lt;/template&gt;
  &lt;template name="addPlayerForm"&gt;
     {{#if currentUser}}
        &lt;form&gt;
           &lt;input type="text" name="playerName"&gt;
           &lt;input type="submit" value="Add Player"&gt;
        &lt;/form&gt;
     {{/if}}
  &lt;/template&gt;
       </code></pre>
  </div>
  </div>
  </p>
  
  <p>I am  new to meteor now learning methods and security issues .
  while i was executing my code it is showing "Exception while simulating the effect of invoking 'insertPlayerData' Reference Error: currentUserId is not defined" error .        </p>