Homework for 4B

Review

Topics Covered: hashes, sinatra review

Exercises

Note: All exercises must live inside of your s0203_exercises/firstname_lastname/d4 folder

While inside of your s0203_exercises directory, you can git add . then git commit -m "Helpful commit message here" and git push origin master to submit your homework to GitHub. (Don't forget to use git status along the way to check the state of your files in git)

Phone Book Sinatra App

Create a Sinatra App, phonebook_app, that will list the contact info of some of your classmates.

In app.rb, define 3 different routes:

  1. a root '/'

    • links to index view which gives you the option to see all contacts or a specific contact
  2. a route to display all the contacts '/contacts'

    • links to contacts view
    • you will also need to define an array that has the names of 3 of your classmates and assign that to an instance variable @contacts
  3. a route to display a single contact '/contacts/:name'.

    • you will need to define a hash that maps the classmates names' from above to his or her phone number. Assign that hash to a variable contacts
    • think about what you want displayed in the contact view. You will probably want to assign those two pieces of information to instance variables so you can access them in the view. Think about how to use parameters in the route to display a specific person's contact information!

BONUS