Skip to content

Instantly share code, notes, and snippets.

@aidataguy
Created June 19, 2016 11:05
Show Gist options
  • Save aidataguy/a05f628c649a81aae757945c352a8392 to your computer and use it in GitHub Desktop.
Save aidataguy/a05f628c649a81aae757945c352a8392 to your computer and use it in GitHub Desktop.
// Destroy Route (need to work on Destroy)
app.post("/blogs/:id", function (req, res) {
/* body... */
// destroy Blog
Blog.findByIdAndRemove(req.params.id, function (err) {
/* body... */
if (err) {
res.redirect("/blogs");
}else {
res.redirect("/blogs");
}
})
// redirect somewhere
});
<div class="ui main text container segment">
<div class="ui huge header"><%= blog.title %></div>
<div class="ui top attached ">
<div class="item">
<img src="<%= blog.image %>" alt="<%= blog.title %>" class="ui centered rounded image">
</div>
<div class="content">
<span><%= blog.created.toDateString() %></span>
</div>
<div class="description">
<p><%= blog.body %></p>
</div>
<form action="/blogs/<%= blog._id %>?_method=DELETE" method="POST">
<button class="ui red basic big button">Delete</button>
</form>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment