Associations II

Model many-to-many relationships to build powerful Rails apps.

Start[missing "en.views.course_landing_page.learn-rails.course_illustration" translation]
Associations II
Lesson 1 of 1
  1. 1

    So far we've made an app that stores data using two models. We used the [...] / [...] association to model a one-to-many relationship between the data. But not all data is one-to-many. For exa...

  2. 2

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

  3. 3

    What did we just do? Check out the diagram in the browser: 1. We created three models - [...] , [...] , and [...] . 2. In the models, we used the [...] association to connect the [...] mode...

  4. 4

    Nice work! Let's review what we did: 1. We added columns to the movies table and actors table 2. We used the [...] methods in the parts table to add foreign keys, setting up the many-to-many rel...

  5. 5

    Well done! The movies show up on the page. Let's add another action to display a specific movie and its actors. Looking at the [seven standard controller actions](https://www.codecademy.com/articl...

  6. 6

    Great job! The app displays all actors that belong to a movie. The [...] association lets us easily query for all actors that belong to a movie.

  7. 7

    Congratulations! You build a movie website that lets people browse a movie's cast and an actor's filmography. What can we generalize so far? * Actors and movies can be modeled using a _many-to-many...

How you'll master it

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

Pro Logo

Associations II

Start[missing "en.views.course_landing_page.learn-rails.course_illustration" translation]