I have this association
@derive {Jason.Encoder,
only: [
:id,
:title,
:user
]}
schema "staff" do
field(:title, :string)
timestamps()
belongs_to(:user, Realest8.Accounts.User)
end
Though I am trying to get user with associated roles
def list_staffs_by_organization(organization_id) do
from(s in Staff,
where: s.organization_id == ^organization_id
)
|> Repo.all() |> Repo.preload([{:user, [:roles]}])
end
I am getting staff details and a nested user object but roles are not included.