diff --git a/controllers/articles.js b/controllers/articles.js index 54bde25..0985eec 100644 --- a/controllers/articles.js +++ b/controllers/articles.js @@ -32,8 +32,11 @@ router.post('/', function(req, res){ router.get('/:id', function(req,res){ Article.findById(req.params.id, function(err, foundArticle){ - res.render('articles/show.ejs', { - article: foundArticle + Author.findOne({'articles._id':req.params.id}, function(err, foundAuthor){ + res.render('articles/show.ejs', { + author: foundAuthor, + article: foundArticle + }); }); }); }); diff --git a/views/articles/show.ejs b/views/articles/show.ejs index 997527e..88e5e4a 100644 --- a/views/articles/show.ejs +++ b/views/articles/show.ejs @@ -6,7 +6,7 @@
-

<%=article.title%>

+

<%=article.title%> by <%=author.name%>