I have a user model which mount a carrierwave uploader for a field called profile_img. code folows:
class User < ActiveRecord::Base
mount_uploader :profile_img, ProfileUploader
end
the output of profile_img field is like this:
"profile_img": {
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/cola_iOS2_512_dribbble2.png",
"thumb": {
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/thumb_cola_iOS2_512_dribbble2.png"
},
"medium": {
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/medium_cola_iOS2_512_dribbble2.png"
}
}
When I try to customize serialize hash by simply calling super,
def serializable_hash(options = {})
super(options)
end
the profile_image field key get duplicated
"profile_img": {
"profile_img": { #### duplicate here
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/cola_iOS2_512_dribbble2.png",
"thumb": {
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/thumb_cola_iOS2_512_dribbble2.png"
},
"medium": {
"url": "https://halo-img-dev.s3.amazonaws.com/uploads/user/profile_img/1000/medium_cola_iOS2_512_dribbble2.png"
}
}
},
I suspect this issue rooted from carrierwave serialize method, but can not find a solution on it.