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

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