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

Explain how to access attachments before save #37005

Closed
wants to merge 1 commit into from

Conversation

ahmeij
Copy link

@ahmeij ahmeij commented Aug 21, 2019

Summary

Explain how to access attachments before save since the files will not be sent to storage anymore before the model is saved. This was changed here: #33303

@rails-bot rails-bot bot added the docs label Aug 21, 2019
@ahmeij
Copy link
Author

ahmeij commented Aug 21, 2019

Sorry, I added [ci skip] to the comment above, not the commit message.

@georgeclaghorn
Copy link
Contributor

attachment_changes is intentionally internal API. If we want to make it possible to access attachables before save, we should expose a nicer public API for it.

@ahmeij
Copy link
Author

ahmeij commented Aug 21, 2019

Good feedback. I would've liked the chance to update this change request with code to expose this functionality, but reading between the lines I am unsure if that would be merged.

I do see however a clear reason for having access to the uploaded file before save. The current setup makes ActiveStorage a bit weird, all changes to the record are visible during validation and before_save, the attachments are becoming the only exception.

Please let know if something along the lines of avatar_file = record.avatar.uploaded is something worth creating a new pull-request for.

@georgeclaghorn
Copy link
Contributor

Please do open a new PR (though I can’t promise that it’ll be accepted sight unseen).

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

Successfully merging this pull request may close these issues.

None yet

2 participants