From bd589f1e0d54cc9855f2e7fff39575139d9ec7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 26 Jan 2025 16:33:39 +0100 Subject: [PATCH] Simplify ShowLive to avoid handle_params (#6059) * Simplify ShowLive to avoid handle_params * mix format --- priv/templates/phx.gen.live/show.ex | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/priv/templates/phx.gen.live/show.ex b/priv/templates/phx.gen.live/show.ex index 445a66fc07..46379eb698 100644 --- a/priv/templates/phx.gen.live/show.ex +++ b/priv/templates/phx.gen.live/show.ex @@ -27,13 +27,8 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web end @impl true - def mount(_params, _session, socket) do - {:ok, socket} - end - - @impl true - def handle_params(%{"id" => id}, _, socket) do - {:noreply, + def mount(%{"id" => id}, _session, socket) do + {:ok, socket |> assign(:page_title, "Show <%= schema.human_singular %>") |> assign(:<%= schema.singular %>, <%= inspect context.alias %>.get_<%= schema.singular %>!(id))}