我正在尝试将数据从API响应(JSON)呈现到我的视图中。 由于某些原因,我只能访问toplevel对象而没有任何问题。BUt当我开始从嵌套对象中检索数据时,我的知识是有限的。> <# This here is the problem how to render the url object which is part of "heroimage" parent 我正在使用的<
在从JSON呈现Ruby-on-Rails时,我需要避免出现空字段: def index render json: @items,
end 如果我的Item对象包含nil字段,则它们在JSON中被序列化为null。我只想从我的JSON中消除空字段。 有没有用于此目的的render选项?这篇文章的答案也没有提到如何做到这一