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

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.