From 6f7a6e128836a44c48c98a75ced78299d36ed83b Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sat, 10 Dec 2016 14:03:19 +0000 Subject: [PATCH] Tidy the fuck up a little --- web/controllers/api/game_controller.ex | 4 +--- web/controllers/game_controller.ex | 20 -------------------- web/router.ex | 2 +- web/templates/game/edit.html.eex | 6 ------ web/templates/game/new.html.eex | 6 ------ 5 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 web/templates/game/edit.html.eex delete mode 100644 web/templates/game/new.html.eex diff --git a/web/controllers/api/game_controller.ex b/web/controllers/api/game_controller.ex index 9b03e56..eac8b71 100644 --- a/web/controllers/api/game_controller.ex +++ b/web/controllers/api/game_controller.ex @@ -14,9 +14,7 @@ defmodule Chess.Api.GameController do case Repo.update(changeset) do {:ok, game} -> - render conn, "show.json", game: game - {:error, changeset} -> - render(conn, "edit.html", game: game, changeset: changeset) + render(conn, "show.json", game: game) end end diff --git a/web/controllers/game_controller.ex b/web/controllers/game_controller.ex index dc90bae..c5a06ec 100644 --- a/web/controllers/game_controller.ex +++ b/web/controllers/game_controller.ex @@ -27,26 +27,6 @@ defmodule Chess.GameController do render(conn, "show.html", game: game) end - def edit(conn, %{"id" => id}) do - game = Repo.get!(Game, id) - changeset = Game.changeset(game) - render(conn, "edit.html", game: game, changeset: changeset) - end - - def update(conn, %{"id" => id, "game" => game_params}) do - game = Repo.get!(Game, id) - changeset = Game.changeset(game, game_params) - - case Repo.update(changeset) do - {:ok, game} -> - conn - |> put_flash(:info, "Game updated successfully.") - |> redirect(to: game_path(conn, :show, game)) - {:error, changeset} -> - render(conn, "edit.html", game: game, changeset: changeset) - end - end - def delete(conn, %{"id" => id}) do game = Repo.get!(Game, id) diff --git a/web/router.ex b/web/router.ex index 3dc4049..ec8fdd0 100644 --- a/web/router.ex +++ b/web/router.ex @@ -17,7 +17,7 @@ defmodule Chess.Router do pipe_through :browser # Use the default browser stack get "/", PageController, :index - resources "/games", GameController + resources "/games", GameController, only: [:create, :show, :delete] end # Other scopes may use custom stacks. diff --git a/web/templates/game/edit.html.eex b/web/templates/game/edit.html.eex deleted file mode 100644 index d9919d9..0000000 --- a/web/templates/game/edit.html.eex +++ /dev/null @@ -1,6 +0,0 @@ -

Edit game

- -<%= render "form.html", changeset: @changeset, - action: game_path(@conn, :update, @game) %> - -<%= link "Back", to: game_path(@conn, :index) %> diff --git a/web/templates/game/new.html.eex b/web/templates/game/new.html.eex deleted file mode 100644 index 169e331..0000000 --- a/web/templates/game/new.html.eex +++ /dev/null @@ -1,6 +0,0 @@ -

New game

- -<%= render "form.html", changeset: @changeset, - action: game_path(@conn, :create) %> - -<%= link "Back", to: game_path(@conn, :index) %>