From ef416174f7605003d317a848dc438296eecd2d71 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Sep 2019 18:15:01 -0300 Subject: [PATCH] asegurar que haya una conexion disponible --- app/models/metadata_image.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/metadata_image.rb b/app/models/metadata_image.rb index 292f520b..9da909a6 100644 --- a/app/models/metadata_image.rb +++ b/app/models/metadata_image.rb @@ -71,11 +71,13 @@ class MetadataImage < MetadataTemplate # # @return ActiveStorage::Attachment def static_file - if uploaded? - blob = ActiveStorage::Blob.find_by(key: key_from_path) - @static_file ||= site.static_files.find_by(blob_id: blob.id) - elsif site.static_files.attach(value['path']) - @static_file ||= site.static_files.last + ActiveRecord::Base.connection_pool.with_connection do + if uploaded? + blob = ActiveStorage::Blob.find_by(key: key_from_path) + @static_file ||= site.static_files.find_by(blob_id: blob.id) + elsif site.static_files.attach(value['path']) + @static_file ||= site.static_files.last + end end end