Hello, I am tryin to implement my “players” (phoenix resource) in “gladiators” (resource). I think everything is right, but I still get the error that " assign @players not available in eex template." (the template is .leex).
To mention - My Phoenix version is 1.5.8
, I do the same in an another project and everything is just fine…
My gladiator live is:
defmodule TennisWeb.GladiatorLive do
use TennisWeb, :live_view
alias TennisWeb.GladiatorView
alias Tennis.Players
alias Tennis.Accounts
alias Tennis.Tours
def render(assigns) do
render GladiatorView, "show.html", assigns
end
@impl true
def mount(params, %{"admin_token" => admin_token} = _session, socket) do
gladiator = Tours.get_gladiator!(params["id"])
players = Players.list_players
admin = Accounts.get_admin_by_session_token(admin_token)
socket = assign(
socket,
gladiator: gladiator,
players: players,
current_admin: admin
)
{:ok, socket}
end
end
The Routes are
resources "/gladiators", GladiatorController
resources "/players", PlayerController
live "/gladiator_live/:id", GladiatorLive
The gladiator :show:
# show,html.leex
<tbody>
<%= for player <- @players do %>
<tr>
<td class="px-4 py-3"> <%= player.name %> </td>
<tr>
(...)
I’m in dead end, thoughts?