April 2018
Beginner to intermediate
406 pages
9h 33m
English
We need to hook this amazing new logic up to our Vote controller's index function if we'd like to start taking advantage of it! We'll start it off simply enough and not worry about hooking up the paging portions of our code and verifying the end results. Our new index function in lib/vocial_web/controllers/poll_controller.ex should look something like this:
def index(conn, params) do %{"page" => page, "per_page" => per_page} = Map.merge(%{"page" => 0, "per_page" => 25}, params) polls = Votes.list_most_recent_polls(page, per_page) render conn, "index.html", polls: polls end
The first line in this controller (other than us changing the function arguments to actually care about params again) is the Map.merge statement. ...
Read now
Unlock full access