Implementing message functions in our context

We'll start with the easiest functionality to implement and then we'll spend a little bit of time writing some tests for our new functions as well. One thing we'll also need to do is clean up some of the broken tests that are the result of the work from the last chapter; we'll tackle that as well. First, in our Votes context (lib/vocial/votes/votes.ex), we'll need to add an alias statement for our new message schema:

  alias Vocial.Votes.Message

Next, we'll continue by implementing the simplest bit of functionality: the list_messages/0 function. This will give us a list of messages not associated with a Poll. We'll add this to our votes context:

  def list_lobby_messages do    Repo.all( from m in Message, ...

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.