Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Creating our Poll schema

A schema in Ecto needs one use statement and one import statement by default. In addition, we want to namespace the modules that we define for our new schema with the name of the app (but not the web app!) and the name of the context. We created votes as the subdirectory under the app "Vocial", so we'll create our module as Vocial.Votes.Poll. Next, we need to tell Ecto that this file will be using all of the Ecto functions and helpers that are available to us.

The schema will also be in charge of telling Ecto how to build changesets to modify data in our database, so we'll need to include that functionality via an import statement. We’ll also want to make our lives easier by including an alias for our full module ...

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

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content