Skip to content

Commit

Permalink
Update LiveView docs (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
slashmili authored Feb 13, 2025
1 parent f1b29aa commit a9e8829
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/phoenix_ecto/sql/sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ defmodule Phoenix.Ecto.SQL.Sandbox do
Now you can use the `on_mount/4` callback to check the header and assign the sandbox:
defmodule MyApp.LiveAcceptance do
import Phoenix.LiveView
import Phoenix.Component
def on_mount(:default, _params, _session, socket) do
%{assigns: %{phoenix_ecto_sandbox: metadata}} =
assign_new(socket, :phoenix_ecto_sandbox, fn ->
if connected?(socket), do: get_connect_info(socket, :user_agent)
end)
Phoenix.Ecto.SQL.Sandbox.allow(metadata, Ecto.Adapters.SQL.Sandbox)
{:cont, socket}
end
end
Expand Down

0 comments on commit a9e8829

Please sign in to comment.