O'Reilly logo

Programming Phoenix by Jose Valim, Bruce Tate, Chris McCord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Repository to Add Data

With our database ready, we can begin to persist our User structs. Let’s hop into an IEx shell and create the users that we previously hard-coded in our in-memory repository. We’ll worry about hashing the password later.

This Is a Bad Idea

images/aside-icons/warning.png

You don’t want to store plain-text passwords into your database! We’ll temporarily save plain-text passwords only as an intermediate step toward a more sophisticated user authentication system.

Spin up your console with iex -S mix, and insert some data:

 iex>​ alias Rumbl.Repo
 iex>​ alias Rumbl.User
 
 iex>​ Repo.insert(%User{
 ...>​ ​name:​ ​"​​José"​, ​username:​ ​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required