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 message 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
<.flash_group flash={@flash} />