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

Creating Some Users

Rather than bog down in a digression on databases, data libraries, and related concerns, let’s agree to keep things simple in the beginning. We’ll start with a few hard-coded users. This strategy will help us in the long run too, because it’ll allow us to test our actions, views, and templates quickly, without needing to create a full database underneath.

Let’s define a Rumbl.User module with the fields id, name, username, and password:

 defmodule​ Rumbl.User ​do
  defstruct [​:id​, ​:name​, ​:username​, ​:password​]
 end

The User module defines an Elixir struct, which is Elixir’s main abstraction for working with structured data.

Elixir Structs

Elixir structs ...

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