mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 19:06:23 +00:00
subir los archivos desde el editor al sitio
This commit is contained in:
parent
bfb8e95599
commit
85cab49208
3 changed files with 24 additions and 4 deletions
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActiveStorage
|
||||
# Modifica la creación de un blob antes de subir el archivo para que
|
||||
# incluya el JekyllService adecuado.
|
||||
module DirectUploadsControllerDecorator
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
def create
|
||||
blob = ActiveStorage::Blob.create_before_direct_upload!(service_name: session[:service_name], **blob_args)
|
||||
render json: direct_upload_json(blob)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActiveStorage::DirectUploadsController.include ActiveStorage::DirectUploadsControllerDecorator
|
|
@ -6,6 +6,7 @@ class PostsController < ApplicationController
|
|||
rescue_from Pundit::NilPolicyError, with: :page_not_found
|
||||
|
||||
before_action :authenticate_usuarie!
|
||||
before_action :service_for_direct_upload, only: %i[new edit]
|
||||
|
||||
# TODO: Traer los comunes desde ApplicationController
|
||||
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
|
||||
|
@ -166,4 +167,9 @@ class PostsController < ApplicationController
|
|||
def post
|
||||
@post ||= site.posts(lang: locale).find(params[:post_id] || params[:id])
|
||||
end
|
||||
|
||||
# Recuerda el nombre del servicio de subida de archivos
|
||||
def service_for_direct_upload
|
||||
session[:service_name] = site.name.to_sym
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,10 +17,6 @@ module ActiveStorage
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Mantener retrocompatibilidad con cómo gestionamos los archivos
|
||||
# subidos hasta ahora.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue