Associations I
Lesson 1 of 1
  1. 1

    We built a Rails app that stores data using a single model. What if we want to build an app with more than one kind of data, like Team and Athlete? Both Team and Athlete would have have different …

  2. 2

    Great! Looking at the request/response cycle, we need four parts to build the travel app: models, controllers, routes, and views. Let’s begin by creating the models.

  3. 3

    What did we just do? 1. We created two models named Tag and Destinations. 2. In the model files, we used the methods […] and […] define an association between Tag and Destination: - […

  4. 4

    Nice work. What did we just do? 1. We added two string columns […] and […] to the tags table 2. We added three string columns […] , […] , and […] to the destinations table 3. We …

  5. 5

    Well done! The app now displays a list of tags from the database.

  6. 6

    Nice job! The app displays all destinations that belong to a tag. How does this work? - When a user visits http://localhost:8000/tags/1, the route […] sends this request to the Tags controller…

  7. 7

    Great! The app now displays a specific destination. Let’s continue by adding actions to update a destination’s name and description. Looking at the seven standard Rails actions, we need to use the…

  8. 8

    Nicely done! You can now update a destination’s name and description. How does it work? When you visit http://localhost:8000/destinations/1/edit to edit a destination, it triggers the first turn o…

  9. 9

    Congratulations! You built an travel app that uses a database to store two kinds of data. What can we generalize so far? - We connected a Tag to its Destinations using associations. In this case…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo