mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Process correct attachment when model has several
Luckily Paperclip has designated callbacks for processing each attachment separately. We can just hook into that.
This commit is contained in:
@@ -22,10 +22,10 @@ module HasMigratingFile
|
||||
# We store files with Paperclip *and* Active Storage while we migrate
|
||||
# old Paperclip files to Active Storage. This enables availability
|
||||
# during the migration.
|
||||
after_post_process do
|
||||
if public_send(name).errors.blank?
|
||||
file = File.open(processed_local_file_path)
|
||||
attach_file(name, file)
|
||||
public_send("after_#{name}_post_process") do
|
||||
path = processed_local_file_path(name)
|
||||
if public_send(name).errors.blank? && path.present?
|
||||
attach_file(name, File.open(path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user