a-thousand-channels / ORTE-backend

Application for creating and managing places (or "Orte") on a map
GNU General Public License v3.0
2 stars 3 forks source link

Fix before_save behavior on attachment upload #293

Closed Sefux closed 9 months ago

Sefux commented 9 months ago

This is a follow up/rewrite to PR #291

Since rail 6 the workflow of the uploading has changed (see https://stackoverflow.com/a/57591408) Further reading: https://github.com/rails/rails/pull/33303 & https://github.com/rails/rails/pull/37005

So not only does the moment of upload change, but we have a difference in the behavior of an upload file vs a file from local file system (attachment_changes['file'].attachable[:io] vs attachment_changes['file'].attachable). This pr tries to handle this.

Furthermore there is a switch to stop attachment change tracking and infinite loops by disabling the before_save hook.

Sefux commented 9 months ago

And add a new helper scope for image model => "without_attached_file" to find all images without an attachment