Skip to content

Commit

Permalink
Simplify ShowLive to avoid handle_params (#6059)
Browse files Browse the repository at this point in the history
* Simplify ShowLive to avoid handle_params

* mix format
  • Loading branch information
josevalim authored Jan 26, 2025
1 parent 042ce91 commit bd589f1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions priv/templates/phx.gen.live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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))}
Expand Down

0 comments on commit bd589f1

Please sign in to comment.