Homework: H5 MVC Model

For this homework, you will create simple model classes in Rails, create seed records for those models, create index and show actions that render webpages that display the records (either individually or as a group), and practice using the basic version control features of Git.

The tasks you will perform draw heavily from this demonstration:

The specific tasks are detailed below. For each one of them:

  1. Create the model class as specified in a UML class diagram.
  2. Run the migrations to update the database and schema file.
  3. Write code to create seed records for the model as specified.
  4. Populate the database with the seed data.
  5. Create a controller for the model.
  6. Create an index controller action (with corresponding route and view) that renders a webpage that displays all records in the database and is formatted as shown in a figure.
  7. Create a show action (with corresponding route and view) that renders a webpage that displays an individual record by ID and is formatted as shown in a figure.
  8. Once you have completed the task, commit the current version of the code to your local repo, and push the changes to the remote GitHub repo.

Task 1: Book Model

UML class diagram depicting a model class
Figure 1.1
Table 1.1
title publisher publication_date isbn genre
American Gods William Morrow, Headline 19 June 2001 0-380-97365-0 Fantasy
Good Omens: The Nice and Accurate Prophecies of Agnes Nutter, Witch Gollancz (UK) / Workman (US) 1 May 1990 0-575-04800-X Comedy
The Colour of Magic Colin Smythe 24 November 1983 0-86140-324-X Fantasy
Screen shot of a webpage
Figure 1.2
Screen shot of a webpage
Figure 1.3

Task 2: Author Model

UML class diagram depicting a model class
Figure 2.1
Table 2.1
first_name last_name webpage dob dod
Terry Pratchett nil 28 April 1948 12 March 2015
Neil Gaiman http://neilgaiman.com/ 10 November 1960 nil
J. K. Rowling http://jkrowling.com/ 31 July 1965 nil
Screen shot of a webpage
Figure 2.2
Screen shot of a webpage
Figure 2.3a
Screen shot of a webpage
Figure 2.3b

Task 3: Review Model

UML class diagram depicting a model class
Figure 3.1
Table 3.1
score summary full_text
5 This grand tale of ancient gods struggling to survive in today's USA has a chilly setting but provides a great summer escape.

Beaches, like books, offer a dislocation from reality, and when taken together the effect is multiplied many times. I love getting lost in a narrative then being jarred out of it by a noisy fellow holidaymaker and looking up, blinking, to remember I'm lying awkwardly on a towel on some sun-kissed shore, miles from home.

Like the terra firma of a beach bordering the seemingly endless sea spooling out and away from the land, Neil Gaiman's American Gods offers that same sense of being anchored to reality but at the same time being merely a bulwark against something massive and frightening and ultimately unknowable.

It seems a little odd now, given his ubiquity, but when American Gods was published in 2001 Gaiman wasn't a household name, unless your household happened to be filled with long-boxes of the comic books on which he had built his career. It wasn't his first, but American Gods feels like his first proper novel; previous outings had been Neverwhere, which was essentially a novelisation of his own screenplay for a BBC TV production whose budget never quite matched his imagination, and Stardust, a slight (though satisfying) fairytale originally conceived as an illustrated book with the artist Charles Vess.

4 Gaiman's storytelling is the furthest thing from clumsy — extremely well researched, superbly clever, and endlessly fun — so American Gods is a con worth falling for.

Gaiman's cast of "old gods" includes gods from all over the world. There's Odin, of course, along with a number of others from Norse mythology. There's also Anansi from African folklore and Bilquis, the Bible's Queen of Sheba, and many, many more. Gaiman handles them all brilliantly, but what's really genius is how he gives them a back story. The novel's epigraph poses the question of "what happens to demonic beings when immigrants move from their homelands”; Gaiman takes this question and runs with it. His answer is that these "demonic beings” don't just appear on American soil. They migrate here, carried from other continents in the minds of their believers.

These days, life ain't easy for the old gods. They face stiff competition in the "new gods” — media and technology and drugs. People no longer believe in the old gods, so they no longer make sacrifices to them, so the old gods are fading away. The old gods must take a stand against the new gods or face elimination. We follow along as Wednesday and Shadow round up the troops in preparation for battle.

2 There is so much going on, so many little details to keep track of, and yet it still manages to come together quite nicely to form a great story about what it means to be human.

Good Omens: The Nice and Accurate Prophecies of Agnes Nutter, Witch is a contemporary and comedic fantasy written by Neil Gaiman and Terry Pratchett in 1990. The collaboration between two of the finest fantasy authors of our generation is nothing short of brilliant, and while they both shared everything equally and did it for fun, Pratchett has said they wouldn't do it again for a big clock.

The antichrist has been born, the four bikers of apocalypse have gathered, its the end of the world as we know it and its all happening in the small english suburb of Lower Tadfield. This is not the news the angel Aziraphale and the demon Crowley had been hoping for as they have become quite accustomed to their lives on earth and are starting to have second thoughts about the whole Armageddon thing. Despite being mortal enemies they decide to work together to help raise the antichrist in the hope that when it comes time for the apocalypse, the antichrist might just decide not to carry through with it. If only those meddling satanic nuns hadn't got to him first...

Screen shot of a webpage
Figure 3.2
Screen shot of a webpage
Figure 3.3

Task 4: User Model

UML class diagram depicting a model class
Figure 4.1
Table 4.1
first_name last_name email
Homer Simpson homer@email.com
Lisa Simpson lsimp@hotmail.com
Bart Simpson bsmpson@memphis.edu
Screen shot of a webpage
Figure 4.2
Screen shot of a webpage
Figure 4.3