diff --git a/controllers/authors.js b/controllers/authors.js index 6e9c51d..561d763 100644 --- a/controllers/authors.js +++ b/controllers/authors.js @@ -63,4 +63,13 @@ router.post('/:id/articles', function(req, res){ }); }); +router.delete('/:authorId/articles/:articleId', function(req, res){ + Author.findById(req.params.authorId, function(err, foundAuthor){ + foundAuthor.articles.id(req.params.articleId).remove(); + foundAuthor.save(function(){ + res.redirect('/authors/' + req.params.authorId + '/edit'); + }) + }); +}); + module.exports = router; diff --git a/views/authors/edit.ejs b/views/authors/edit.ejs index 4cecb10..f8e48b3 100644 --- a/views/authors/edit.ejs +++ b/views/authors/edit.ejs @@ -30,7 +30,12 @@

Articles Written By This Author