From 5356c9f9f142b60aa4552d48ec16b29a9af99ae3 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 15 Jan 2019 13:11:07 +0100 Subject: [PATCH] Refactoring: Make asset fetch more robust for records referring to deleted records. --- app/models/application_model/can_assets.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/application_model/can_assets.rb b/app/models/application_model/can_assets.rb index c1f084390..5a15d9897 100644 --- a/app/models/application_model/can_assets.rb +++ b/app/models/application_model/can_assets.rb @@ -145,7 +145,9 @@ get assets of object list def assets_of_object_list(list, assets = {}) list.each do |item| require_dependency item['object'].to_filename - record = Kernel.const_get(item['object']).find(item['o_id']) + record = Kernel.const_get(item['object']).lookup(id: item['o_id']) + next if record.blank? + assets = record.assets(assets) if item['created_by_id'].present? user = User.find(item['created_by_id'])