Phoenix Flash Message
From ElixirBlocks
In Phoenix the flash message is invoked from the controller.
def create(conn, %{"doink" => doink_params}) do case Doinks.create_doink(doink_params) do {:ok, doink} -> conn |> put_flash(:info, "Doink created successfully.") |> redirect(to: ~p"/doinks/#{doink}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, :new, changeset: changeset) end end
The flash component itself needs to be in the view. For a new instance it defaults to being in the the layout via app_web/layouts/app.html.heex and its accessible to all controllers.
<.flash_group flash={@flash} />