Try this:
%{usuarios: render_many(usuarios, UsuariosWeb.UserView, "usuario.json", as: :usuario)}
The underlying user is passed to the view and template as
:user, which is inferred from the view name.
which means that
%{usuarios: render_many(usuarios, UsuariosWeb.UserView, "usuario.json")}
is equivalent to:
Enum.map(usuarios, fn user ->
render(UserView, "usuario.json", user: user)
end)
because your view is named UserView.
As a side not, I think you can just use if in your controllers:
if usuario = Usuarios.User.buscar_usuario(id) do
# conn ...
else
{:error, "usuario no encontrado!"}
end


















