Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Need a convenient method to get original field real value #17

Open
zw963 opened this issue Oct 21, 2015 · 3 comments
Open

Comments

@zw963
Copy link

zw963 commented Oct 21, 2015

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.

@zw963 zw963 changed the title Need a convenient method to get original field real value. [Feature Request] Need a convenient method to get original field real value Oct 21, 2015
@timfjord
Copy link
Owner

It is probably a bit late, but feel free to open a PR with the proposed change

@zw963
Copy link
Author

zw963 commented Apr 14, 2021

Long long ago ... i am afraid forget why create this issue ...

@timfjord
Copy link
Owner

timfjord commented Apr 14, 2021

😄 I am going to keep it for now, maybe someone else will be interested in it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants