1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Tidy the fuck up a little

This commit is contained in:
Daniel Barber 2016-12-10 14:03:19 +00:00
parent 47f287aaa4
commit 6f7a6e1288
5 changed files with 2 additions and 36 deletions

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -1,6 +0,0 @@
<h2>Edit game</h2>
<%= render "form.html", changeset: @changeset,
action: game_path(@conn, :update, @game) %>
<%= link "Back", to: game_path(@conn, :index) %>

View File

@ -1,6 +0,0 @@
<h2>New game</h2>
<%= render "form.html", changeset: @changeset,
action: game_path(@conn, :create) %>
<%= link "Back", to: game_path(@conn, :index) %>