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

after_assign's copy_to doesn't fire when using retained_image #503

Open
rdunlop opened this issue Oct 3, 2019 · 1 comment
Open

after_assign's copy_to doesn't fire when using retained_image #503

rdunlop opened this issue Oct 3, 2019 · 1 comment

Comments

@rdunlop
Copy link

rdunlop commented Oct 3, 2019

My model has 2 attachments

  • original_uid
  • image_uid
    dragonfly_accessor :original do
      copy_to :image
    end
    dragonfly_accessor :image do
      after_assign :process_image
    end

I am also using retained_original in my form.

The problem seems to be that:

  • If I upload a graphic, and submit the form
  • And the form Fails validation (thus filling the retained_original)
  • And then I fix the form issue
  • When I submit the form, the original_uid is set but the image_uid is NOT set.

Based on reading the source code it looks like the "retained_#{attribute}=" method does not go through the dragonfly_attachments[attribute].assign(value) path, which prevents the after_assign callback from being fired.

My only idea right now is to remove the retained_original usage, since this is causing my models to end up in an unexpected situation.

Please let me know if I'm using these 2 features together incorrectly.

@rdunlop
Copy link
Author

rdunlop commented Oct 3, 2019

This appears to be the same as #348 (comment)

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

No branches or pull requests

1 participant