我有一个名为 Recipe 的模型,它有 2 个使用载波的图像,所以在这个模型中我有这个来设置载波
mount_uploader :author_photo, AuthorUploader
mount_uploader :photo, PhotoUploader
我还为我的图像添加了多个版本,例如拇指、小、中、大
问题是。说我有 2 张图片
Chocolate_Cake.jpg as the photo
My_Photo.jpg as author_photo
当我进入控制台并加载我的食谱并加载到 recipe.to_json 时,我从carrierwave 中获取了我的两张图片,但它们都显示了食谱的照片,而不是作者的照片。
"recipe": [
{
"author_photo": {
"url": "/uploads/recipe/photo/8/Chocolate_Cake.jpg",
"thumb": {
"url": "/uploads/recipe/photo/8/thumb_Chocolate_Cake.jpg"
},
"small": {
"url": "/uploads/recipe/photo/8/small_Chocolate_Cake.jpg"
},
"medium": {
"url": "/uploads/recipe/photo/8/medium_Chocolate_Cake.jpg"
},
"large": {
"url": "/uploads/recipe/photo/8/large_Chocolate_Cake.jpg"
}
},
"id": 8,
"photo": {
"url": "/uploads/recipe/photo/8/Chocolate_Cake.jpg",
"thumb": {
"url": "/uploads/recipe/photo/8/thumb_Chocolate_Cake.jpg"
},
"small": {
"url": "/uploads/recipe/photo/8/small_Chocolate_Cake.jpg"
},
"medium": {
"url": "/uploads/recipe/photo/8/medium_Chocolate_Cake.jpg"
},
"large": {
"url": "/uploads/recipe/photo/8/large_Chocolate_Cake.jpg"
}
},
所以由于某种原因,我的 json 响应没有正确显示我的上传者。
如果我要在控制台中输入这个,
recipe.photo
recipe.author_photo
他们想出了不同的图片网址