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

  end

  def show(conn, %{"id" => id}) do
    case Tasks.get(id) do
      {:ok, task} ->
        render(conn, "show.html", task: task)
      {:error, :not_found} ->
        conn
        |> put_status(404)
        |> render(CoursePlannerWeb.ErrorView, "404.html")
      end
  end

  def edit(conn, %{"id" => id}) do
    case Tasks.get(id) do
      {:ok, task} ->
        render(conn, "edit.html", task: task, changeset: Task.changeset(task))
      {:error, :not_found} ->
        conn
        |> put_status(404)
        |> render(CoursePlannerWeb.ErrorView, "404.html")
    end
  end


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