根据变体ID查找哈希
[
{
"id": 3693828997212,
"position": 1,
"created_at": "2018-07-17T03:25:44-06:00",
"updated_at": "2018-07-17T03:25:48-06:00",
"alt": null,
"width": 273,
"height": 320,
"src": "https://cdn.shopify.com/s/files/1/1384/1935/products/HGPC4050B_aeb4f02b-64af-4e2b-8ded-60ddba027683.jpg?v=1531819548",
"variant_ids": [
12341420949596
],
"admin_graphql_api_id": "gid://shopify/ProductImage/3693828997212"
},
{
"id": 3693829455964,
"position": 2,
"created_at": "2018-07-17T03:25:46-06:00",
"updated_at": "2018-07-17T03:25:48-06:00",
"alt": null,
"width": 273,
"height": 320,
"src": "https://cdn.shopify.com/s/files/1/1384/1935/products/HGPC8010B_ee78ecc9-22f1-41e6-899e-a425d7aef6e7.jpg?v=1531819548",
"variant_ids": [
12341420982364
],
"admin_graphql_api_id": "gid://shopify/ProductImage/3693829455964"
}
]
答案 0 :(得分:0)
我假设一个变体ID仅属于一个用户
arr.find { |h| h[:variant_ids].include?(12341420982364) }