Homework for 9A

Review

Topics Covered: Rails relations; validations;


Exercises

E1: Relation Review

  1. Why do we use relations? What are they good for?
  2. Will you ever write a relation on just one class, or will a relation always join two classes together?
  3. What types of relations did we learn about? What makes them unique? Can you give examples of each? Hint: We learned about 3 different kinds and an extension.
  4. What changes do you have to make to migrations and models for each relation?

E2: We Belong Together

What kind of relations would you use for each of the following models?

  1. Tweets and users
  2. Users and accounts
  3. Tweets and hash tags
  4. Stores and customers
  5. Shopping carts and items
  6. Shoppers and Carts
  7. Shopper and items in the cart that the shopper has

E3: Reddit on

Rebuild Reddit up to the end of exercises yesterday from scratch. The reason we're starting from scratch on not our d8 version is simple: repetition breeds memory. It may seem tedious, but please believe that 15 extra minutes now will save you hours later.

This time, we're going to add relations and validations. BEFORE YOU START, think: