Seeding and Associating Categories

Let’s associate videos and categories. The first step is to make sure categories actually exist in our database by using seed data. Then we will change our web interface to allow users to pick the category for a new video.

Setting Up Category Seed Data

We need to define a handful of initial categories for our application to use. We could start an IEx session and directly invoke the repository to do that, but this approach has some issues. If we do this work manually, each teammate will have to do the same as soon as they want to take our application for a spin. Once our application grows in size, having to populate each table in our application with relevant data can get long and tedious.

Furthermore, categories ...

Get Programming Phoenix 1.4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.