From 602390fc8695db9129d1ef2fe3ea85e3e14b9ca7 Mon Sep 17 00:00:00 2001 From: JoshAshby Date: Sat, 21 Dec 2019 20:42:59 -0700 Subject: [PATCH 1/2] try out a hackaround for fixing getting the root attachment seems the attach method changed from rails 5-6 to return true instead of the newly attached attachment? --- lib/webpage_cache_service/cache.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/webpage_cache_service/cache.rb b/lib/webpage_cache_service/cache.rb index c80e9e65..294080c4 100644 --- a/lib/webpage_cache_service/cache.rb +++ b/lib/webpage_cache_service/cache.rb @@ -43,9 +43,9 @@ def exec # Return self since there is an errors object and the offline cache model # that people might care about on this object. self - rescue => e - errors.create key: uri, message: e.message - self + # rescue => e + # errors.create key: uri, message: e.message + # self end private @@ -96,7 +96,7 @@ def get uri: # Without manually managing the temp file, there isn't an easy way to # breakup the following logic but I did my best and fuck you too rubocop - attachments = binary_temp_file do |temp_file| + binary_temp_file do |temp_file| write_body response: response, to: temp_file content_type = get_content_type(response: response, io: temp_file) @@ -110,7 +110,7 @@ def get uri: ) end - attachment = attachments.first + attachment = offline_cache.assets.order(:id).first [ response, attachment ] end From 2bd380800d5580831ae2ad25357335b5392854bd Mon Sep 17 00:00:00 2001 From: JoshAshby Date: Sat, 21 Dec 2019 20:54:42 -0700 Subject: [PATCH 2/2] re-add the rescue for error messages --- lib/webpage_cache_service/cache.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/webpage_cache_service/cache.rb b/lib/webpage_cache_service/cache.rb index 294080c4..ec46d7e8 100644 --- a/lib/webpage_cache_service/cache.rb +++ b/lib/webpage_cache_service/cache.rb @@ -43,9 +43,9 @@ def exec # Return self since there is an errors object and the offline cache model # that people might care about on this object. self - # rescue => e - # errors.create key: uri, message: e.message - # self + rescue => e + errors.create key: uri, message: e.message + self end private