From 6dc4b646c5981fb76a9307e384279d23e2c3f3dd Mon Sep 17 00:00:00 2001 From: ajugo Date: Mon, 3 Jul 2023 13:13:19 +0200 Subject: [PATCH] Add handling for deleted ActiveStorage files [SCI-8264] (#5624) Add handling for deleted ActiveStorage files [SCI-8264] --- .../active_storage/representations/redirect_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/active_storage/representations/redirect_controller.rb b/app/controllers/active_storage/representations/redirect_controller.rb index 38b2f5d9e..a9ac2a9d1 100644 --- a/app/controllers/active_storage/representations/redirect_controller.rb +++ b/app/controllers/active_storage/representations/redirect_controller.rb @@ -6,6 +6,11 @@ module ActiveStorage include ActiveStorage::SetBlob include ActiveStorage::CheckBlobPermissions + rescue_from ActiveRecord::RecordNotFound do |e| + Rails.logger.error(e.message) + render json: {}, status: :not_found + end + def show if @blob.attachments.take.record_type == 'Asset' return render plain: '', status: :accepted unless preview_ready?