Я новичок в API рельсов. Я получаю "TypeError Нет неявного преобразования Symbol в Integer" в консоли сервера rails для следующего синтаксиса.
def show
@product = Product.find(params[:id])
render json: @product.to_json(:include =>
{ :items =>
{ :only =>
[:id,
:description,
:item_name,
:item_code,
:display_tag,
:price,
{:include =>
:item_images [:id,
:image_url]
}
]
}
}
)
end
Он должен показывать массив item_images, а также для элементов при запросе URL (например, http://localhost:4000/products/1) мой JSON выглядит так:
{
"id": 1,
"product_name": "Foundation",
"description": "test",
"image_file_name": "text.jpg",
"image_content_type": "image/jpeg",
"image_file_size": 341279,
"image_updated_at": "2018-10-24T09:28:49.000Z",
"image_url": "http://localhost:3000/system/products/1/original/text.jpg",
"created_at": "2018-08-28T14:50:29.000Z",
"updated_at": "2018-10-24T09:28:50.000Z",
"items": [
{
"id": 6,
"item_name": "LOTUS WHITE GLOW COMPAC POWDER",
"item_code": "SF264",
"display_tag": "New",
"description": "SKIN WHITENING AND BRIGHTENING NOURISHING\r\nSUITABLE FOR ALL SKIN TYPES\r\nULTRA-FINE SILTY FORMULA\r\nSILKY SMOOTH AND DELICATE TEXTURE\r\nCONTAINS NATURAL PLANT INGREDIENTS CAN BLOCK THE INSIDE DARK",
"price": "1250.0"
},
{
"id": 7,
"item_name": "Test",
"item_code": "100",
"display_tag": "New",
"description": "lorem ipsum",
"price": "200.0"
}
]}
Любая помощь?