April 2018
Beginner to intermediate
406 pages
9h 33m
English
Right now, those routes won't work, because they don't yet have a controller action associated with them. Let's hop into our poll_controller.ex file and create the new action:
def new(conn, _params) do poll = Vocial.Votes.new_poll() conn |> put_layout("special.html") |> render "new.html", poll: poll end
First, we start off by creating a new blank poll object. We'll use a function in our context that doesn't actually exist yet. We want to keep our context as the main method of interaction between our controller and our database, so we'll just pick a function name and use that later. Next, we'll basically just copy our index function over from the controller and use that code.
One thing you might notice ...