我不需要在数组中包含特定对象。
Product
有很多line_items
:
控制器:
[...]
# example line_item Table
line_items = [
{id: 1, name: "Static Name", ...},
{id: 2, name: "Other name", ...}
]
@products = Product.order(created_at: :desc).where(domain: @shop.domain).as_json(
include: {
line_items: {
only: [:quantiy, :unit_amount]
}
}
)
[...]
如何不包含名称为Static Name
的哈希?该名称将始终命名。我需要其他物品。