Skip to Main Content
Programming Phoenix
book

Programming Phoenix

by Chris McCord, Bruce Tate, Jose Valim
April 2016
Beginner to intermediate content levelBeginner to intermediate
300 pages
6h 58m
English
Pragmatic Bookshelf
Content preview from Programming Phoenix

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Elm

Programming Elm

Jeremy Fairbank
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781680501926Errata Page