Next up: the user should be able to delete a picture.
A brief diversion: on the list of pictures, let's add a link to the details page for each picture.
Also, let's have a link to each picture's edit form.
Finally, let's add a link to trigger our destroy action. We would like to use the HTTP verb DELETE to reflect our intention, but raw HTML doesn't support that verb, so we again need to use a Rails view helper method: link_to.
Defined a method to handle the destroy a picture request.
Wrote some logic to load up the row from the table, destroy it, and redirect the user to the list of all pictures.
Congratulations -- our app is fully functional. We can Create, Read, Update, and Delete. Now we'll start to refactor our CRUD app to make the code a smidgen better. First, we update the routes file with the shorthand syntax for controllers and actions.
Added a root url.
Removed the default homepage so our root url will work.
Replaced all raw <a> tags with link_to helpers.
Replaced all raw <img> tags with image_tag helpers.
Replaced raw <form> tag with form_tag helpers.
Added navigation links.