When we looked at casting and filtering at the beginning of this chapter, we took different approaches depending on whether or not the data we used was generated in our application code or if it came from an external source. We make a similar distinction when working with associations. We’ll start with internal data using Ecto.Changeset.put_assoc, then use Ecto.Changeset.cast_assoc to work with external data. Before we continue, if you’ve been running these commands on your local setup, you should run the following.

Get hands-on with 1200+ tech skills courses.