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 a Votes context

Our module definition will be Vocial.Votes (not Vocial.Votes.Votes), and in it we'll want to import Ecto.Query so we can build out any special queries that may be required. We'll also want to alias in our Repo, Poll, and Option modules, just like we did in our IEx window. So, our starting skeleton should look like this:

defmodule Vocial.Votes do import Ecto.Query, warn: false alias Vocial.Repo alias Vocial.Votes.Poll alias Vocial.Votes.Optionend
The warn: false option on the import and alias statements tells Elixir not to give warnings when we import or alias something and then don’t use it. It's a good thing to use important functionality imports such as Ecto.Query in a Context, but you should generally try to avoid ...
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