 
   import Canary.Plugs
   plug :authorize_controller
+  action_fallback CoursePlannerWeb.FallbackController
 
   @error_messages %{
     not_found: "Task was not found."

       conn
       |> put_flash(:info, "Task updated successfully.")
       |> redirect(to: task_path(conn, :show, task))
     {:error, :not_found} ->
       conn
       |> put_status(404)
       |> render(CoursePlannerWeb.ErrorView, "404.html")
     {:error, changeset} ->
       render(conn, "edit.html", task: id, changeset: changeset)
    end

  end

  def show(conn, %{"id" => id}) do
    with {:ok, task} <- Tasks.get(id) do
      render(conn, "show.html", task: task)
    end
  end

  def edit(conn, %{"id" => id}) do
    with {:ok, task} <- Tasks.get(id),
         changeset   <- Task.changeset(task)
    do
      render(conn, "edit.html", task: task, changeset: changeset)
    end
  end

