Bidirectional operator key in serializable_hash
I have a custom model that mounts a carrier loader for a field named profile_img. code:
class User < ActiveRecord::Base
mount_uploader :profile_img, ProfileUploader
end
the output of the profile_img field looks 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 set up hash serialization just by calling super,
def serializable_hash(options = {})
super(options)
end
the profile_image field field will be 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 question comes from the serialwave-media method, but cannot find a solution on it.
Any hint?
+3
source to share