jade loop not able to access variable in node.js file

I've been searching for the solution to this for days and would love any solutions or recommendations.

I am building a very simple blog with node.js, express, and mongo db according to this how to node tutorial. I am doing this as practice in order to understand node better, as I'm not very well-versed yet.

I followed all instructions, taking into account differences in versions, and everything runs fine until I get to the heading in the tutorial, "A View to Kill", where I send some dummy data to a jade file to be rendered.

If I leave the code in my app.js file as this with no jade file being passed into it:

var articleProvider= new ArticleProvider();

app.get('/', function(req, res){
  articleProvider.findAll(function(error, docs){
      res.send(docs);
  });
})

app.listen(3000);

I get a render of the data object.

But when I pass in the jade file to be rendered, I get the error:

TypeError: Cannot read property 'length' of undefined

...which refers to the each loop in my jade file (line 3), which is here:

h1= title
#articles
    - each article in articles
      div.article
        div.created_at= article.created_at
        div.title 
            a(href="/blog/"+article._id)!= article.title
        div.body= article.body

Here is the link to the git of the whole damn thing. ANY help at all is greatly appreciated!

The articles reference is undefined. Try changing your render code to the following:

app.get('/', function(req, res){
    articleProvider.findAll(function(error, docs){
        res.render('index.jade', {
            articles: docs
        });
    });
});