asegurar que haya una conexion disponible

This commit is contained in:
f 2019-09-20 18:15:01 -03:00
parent 250468657f
commit ef416174f7
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D

View file

@ -71,6 +71,7 @@ class MetadataImage < MetadataTemplate
# #
# @return ActiveStorage::Attachment # @return ActiveStorage::Attachment
def static_file def static_file
ActiveRecord::Base.connection_pool.with_connection do
if uploaded? if uploaded?
blob = ActiveStorage::Blob.find_by(key: key_from_path) blob = ActiveStorage::Blob.find_by(key: key_from_path)
@static_file ||= site.static_files.find_by(blob_id: blob.id) @static_file ||= site.static_files.find_by(blob_id: blob.id)
@ -78,6 +79,7 @@ class MetadataImage < MetadataTemplate
@static_file ||= site.static_files.last @static_file ||= site.static_files.last
end end
end end
end
private private