5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 11:31:41 +00:00

fix: cambiado metodo blob_for para lanzar excepcion y disk_controller_decorator.rb para devolver not_found si no encuentra el blob #14378

This commit is contained in:
jazzari 2023-11-21 15:45:42 +01:00
parent 7e78fd861a
commit 32fdb4e796
2 changed files with 3 additions and 2 deletions

View file

@ -6,6 +6,7 @@ module ActiveStorage
extend ActiveSupport::Concern
included do
rescue_from ActiveRecord::RecordNotFound, with: :page_not_found
# Asociar el archivo subido al sitio correspondiente. Cada sitio
# tiene su propio servicio de subida de archivos.
def update
@ -13,7 +14,7 @@ module ActiveStorage
if acceptable_content?(token)
named_disk_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum]
blob = ActiveStorage::Blob.find_by_key token[:key]
blob = ActiveStorage::Blob.find_by! token[:key]
site = Site.find_by_name token[:service_name]
site.static_files.attach(blob)

View file

@ -96,7 +96,7 @@ module ActiveStorage
end
def blob_for(key)
ActiveStorage::Blob.find_by(key: key, service_name: name)
ActiveStorage::Blob.find_by!(key: key, service_name: name)
end
end
end