I'm creating a blog site and am trying to implement a function so that users can report specific comments. The idea is that the user will click on a 'report' link beneath a specific comment and be taken to a new page which will be pre-populated with both the comment they are reporting and the title of the blog which the comment belongs to.
I have written the following route so far:
router.get('/blogs/:blog_id/comments/:comment_id/report', function(req, res) {
// find comment
Comment.findById(req.params.comment_id, function(err, foundComment){
if(err){
res.redirect('/blogs');
} else {
res.render('report-comment', {comment: foundComment});
}
});
});
This is successfully generating my report comment page and from the report comment page I can then populate the comment using eps <%=comment.text%>. However, I cannot work out in this route how to pass through the blog details that the comment is embedded within. In my report comment form I want to be able to populate the blog title using <%=blog.title%> but where in my route do I pass the blog info through?
via DaveB1
No comments:
Post a Comment