carrierwave-serializable
carrierwave-serializable copied to clipboard
[Feature Request] Need a convenient method to get original field real value
Some times, I will import some image data from rake task, so, my mounted image
field will have a http://some_site/some_image.png value.
so,I will handle this situation with override uploader url method like this:
def url
# here, if not use a serialize field, model[mounted_as] will get the original value.
original_url = model[mounted_as]
original_url =~ %r{\Ahttps?://} ? original_url : super
end
But if use serialize, model[mounted_as] or model.read_attribute[mounted_as is
not worked anymore,we need a new api to get the correct value.
currently, I have to do like this:
def url
serialize_to = model.class.serialized_uploaders[mounted_as]
original_url = model[serialize_to][mounted_as.to_s]
original_url =~ %r{\Ahttps?://} ? original_url : super
end
Here, if can expose a original_url API, is good. Thanks.
It is probably a bit late, but feel free to open a PR with the proposed change
Long long ago ... i am afraid forget why create this issue ...
😄 I am going to keep it for now, maybe someone else will be interested in it