Router Action running twice - even though this.ready() is checked


#1

Using Iron Router - I have the following code in the action. When i refresh the route (F5) - the else gets called first and then the if, despite the fact i am checking this.ready and have subscribed to the ‘items’ collection with ‘waitOn’

waitOn: function () {
    Meteor.subscribe('items');
  },


action: function () {
    if (this.ready()) {
            if (Items.findOne(  {'slug':this.params.slug}  )){
              console.log("Showing record");
              this.render();
            }
            else{
              console.log("Missing item record");
              FlashMessages.sendWarning("No items with slug <strong>" + this.params.slug + "</strong>");
              //Router.go('createItem');
            }
          } else {
            this.render('Loading');
          }
    }

}