app/controllers/spina/admin/attachments_controller.rb in spina-2.9.1 vs app/controllers/spina/admin/attachments_controller.rb in spina-2.10.0

- old
+ new

@@ -30,16 +30,24 @@ end end def update @attachment = Attachment.find(params[:id]) + old_signed_id = @attachment.file&.blob&.signed_id + @attachment.update(attachment_params) if params[:attachment].present? if params[:filename].present? extension = @attachment.file.filename.extension filename = "#{params[:filename]}.#{extension}" @attachment.file.blob.update(filename: filename) end - - redirect_to [:admin, @attachment] + + # Replace all occurrences of the old signed blob ID + # with the new ID in a background job + if @attachment.reload.file&.blob&.signed_id != old_signed_id + Spina::ReplaceSignedIdJob.perform_later(old_signed_id, @attachment.file&.blob&.signed_id) + end + + render @attachment end def destroy @attachment = Attachment.find(params[:id]) @attachment.destroy