diff --git a/lib/chess_web/controllers/game_controller.ex b/lib/chess_web/controllers/game_controller.ex index f2d8cbc..e690ac1 100644 --- a/lib/chess_web/controllers/game_controller.ex +++ b/lib/chess_web/controllers/game_controller.ex @@ -42,7 +42,10 @@ defmodule ChessWeb.GameController do end def show(conn, %{"id" => id}) do - game = Repo.get!(Game, id) + query = from(game in Game, preload: [:user, :opponent]) + game = + query + |> Repo.get!(id) render(conn, "show.html", game: game) end diff --git a/lib/chess_web/templates/game/show.html.eex b/lib/chess_web/templates/game/show.html.eex index a985599..0203eb8 100644 --- a/lib/chess_web/templates/game/show.html.eex +++ b/lib/chess_web/templates/game/show.html.eex @@ -1,3 +1,5 @@ +
<%= link "Back to games", to: game_path(@conn, :index) %>