mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 09:01:42 +00:00
Merge branch 'issue-14378' into 'rails'
ActiveStorage::Service::JekyllService#blob_for puede devolver nil See merge request sutty/sutty!226
This commit is contained in:
commit
960b34385a
2 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,7 @@ module ActiveStorage
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
|
rescue_from ActiveRecord::RecordNotFound, with: :page_not_found
|
||||||
# Asociar el archivo subido al sitio correspondiente. Cada sitio
|
# Asociar el archivo subido al sitio correspondiente. Cada sitio
|
||||||
# tiene su propio servicio de subida de archivos.
|
# tiene su propio servicio de subida de archivos.
|
||||||
def update
|
def update
|
||||||
|
@ -13,7 +14,7 @@ module ActiveStorage
|
||||||
if acceptable_content?(token)
|
if acceptable_content?(token)
|
||||||
named_disk_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum]
|
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_key! token[:key]
|
||||||
site = Site.find_by_name token[:service_name]
|
site = Site.find_by_name token[:service_name]
|
||||||
|
|
||||||
site.static_files.attach(blob)
|
site.static_files.attach(blob)
|
||||||
|
@ -26,6 +27,12 @@ module ActiveStorage
|
||||||
rescue ActiveStorage::IntegrityError
|
rescue ActiveStorage::IntegrityError
|
||||||
head :unprocessable_entity
|
head :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def page_not_found(exception)
|
||||||
|
head :not_found
|
||||||
|
ExceptionNotifier.notify_exception(exception, data: {params: params.to_hash})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,7 +96,7 @@ module ActiveStorage
|
||||||
end
|
end
|
||||||
|
|
||||||
def blob_for(key)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue