Blog App and RESTful Routing

I finally got through RESTful Routing and while watching these tutorials I also made a blog app using these RESTful routes. I had already used the Index, New, and Create routes before but this was the first time I was introduced to the Show, Edit, Update, and Destroy routes. I first went over the Index route again, the Index displays all the blogs that have been posted.

The two other routes that I went over again was the New and Create route. The new route was where the form to create a blog is held and then the create route is the POST method which adds the new post to the database and then redirects the user back to the Index page. The new post is now listed there.

The next route I learned about was the Show route. This route holds all the information of one post. It hold the title, date, and the content itself that the user has posted. For this route we had to use body-parser to get the id of the blog from the Database and have it added to the route when the user clicked on a blog post.

The next two routes that I was introduced to was the Edit and Update route. The edit route allows the user to edit their post. In this route we grab the blog idea to take the user to the correct post and then we take he content of the post and then place it on the form so the user can edit it. Once the user submits the form the information is taken by the Update route to update the database. The Update route uses a PUT method but since this method doesn’t work with an html form we have to use the Method Override package to be able to use the PUT method.

The last route I was introduced to was the Destroy route. This route allows to delete any blog that has been created. This route searches for the blog by its id and then removes it from the database.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php