Posted on

seed phoenix

Let’s start by creating an alias for that module. Then we’ll call the create_album passing in the attributes we want.

Let’s open our editor. And if we go into our priv/repo directory there’s a file seeds.exs . Phoenix creates this for us as a way to populate our database with some dummy content.
Luckily for us Phoenix provides an easy way for us to populate – or seed – our database with information.

It looks like our album was created – let’s start up our server and see what it looks like.
The we’ll start our server.
In this episode we’ll cover how you can populate – or seed – your database with information.
$ mix run priv/repo/seeds.exs
Great our site looks a lot better – all our albums have been created.

Then below let’s call Enum.each to enumerate over our albums, and for our function, we’ll pass in our album’s data calling Records.create_album! .

In this episode we'll learn how to seed our Ecto database with some dummy info for use in a Phoenix application.