Key :inner_content not found in /../components/layouts/app.html.heex

Hi every one, with my current setup, I have an error with default registration page after run mix phx.gen.auth.

❯ elixir --version
Erlang/OTP 28 [erts-16.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.19.3 (compiled with Erlang/OTP 28)

mix.exs file: defp deps do

\[

  {:argon2_elixir, "\~> 4.0"},

  {:phoenix, "\~> 1.8.1"},

  {:phoenix_ecto, "\~> 4.5"},

  {:ecto_sql, "\~> 3.10"},

  {:postgrex, ">= 0.0.0"},

  {:phoenix_html, "\~> 4.1"},

  {:phoenix_live_reload, "\~> 1.2", only: :dev},

  {:phoenix_live_view, "\~> 1.1.17"},

  {:floki, ">= 0.30.0", only: :test},

  {:phoenix_live_dashboard, "\~> 0.8.3"},

  {:esbuild, "\~> 0.8", runtime: Mix.env() == :dev},

  {:tailwind, "\~> 0.2", runtime: Mix.env() == :dev},

  {:heroicons,

github: “tailwindlabs/heroicons”,

tag: “v2.1.1”,

sparse: “optimized”,

app: false,

compile: false,

depth: 1},

  {:swoosh, "\~> 1.5"},

  {:finch, "\~> 0.13"},

  {:telemetry_metrics, "\~> 1.0"},

  {:telemetry_poller, "\~> 1.0"},

  {:gettext, "\~> 1.0.1"},

  {:jason, "\~> 1.2"},

  {:dns_cluster, "\~> 0.2.0"},

  {:bandit, "\~> 1.5"}

\]

end
router.ex file:

scope “/”, AppWeb do

pipe_through \[:browser\]



live_session :current_user,

on_mount: [{AppWeb.UserAuth, :mount_current_scope}] do

  live "/users/register", UserLive.Registration, :new

  live "/users/log-in", UserLive.Login, :new

  live "/users/log-in/:token", UserLive.Confirmation, :new

end

post "/users/log-in", UserSessionController, :create

delete "/users/log-out", UserSessionController, :delete

end

When use mix phx.gen.auth, the generator generate new version of registration.ex, use Layouts.app, but there is error:

KeyError at GET /users/register
key :inner_content not found in:

    %{
      current_scope: nil,
      inner_block: [
        %{
          inner_block: #Function<2.48550011/2 in AppWeb.UserLive.Registration.render/1>,
          __slot__: :inner_block
        }
      ],
      flash: %{},
      __changed__: nil
    }

Please help to resolve this.

Thanks! :smiley:

1 Like

What is in your layouts.ex file?

1 Like

It is the default content:

defmodule AppWeb.Layouts do
  @moduledoc """
  This module holds different layouts used by your application.

  See the `layouts` directory for all templates available.
  The "root" layout is a skeleton rendered as part of the
  application router. The "app" layout is set as the default
  layout on both `use AppWeb, :controller` and
  `use AppWeb, :live_view`.
  """
  use AppWeb, :html

  embed_templates "layouts/*"
end

You probably have @inner_content in your layout html, but I believe that when you call your layout as a function you have to use render_slot(@inner_block)

Have you tried without the Layouts.app? The recent versions of Phoenix use layouts differently and the generators assume your app does too, but if you are still set up in the previous way you may not need the Layouts.app.

2 Likes

I assume the actual issue here is that you generated the project with the 1.7 installer and then ran the 1.8 mix phx.gen.auth?

If this is a blank project then just regenerate it with the newer installer and start over. If this is an existing app then you can either switch to the newer Layouts approach or modify the generated auth code to use the old approach. I would choose the former as the new approach is better.

2 Likes

Thanks all,

I had create an issue and known that I forgot to upgrade from phoenix project from 1.7.14 to 1.8.1.

1 Like