demarches-normaliennes/app/controllers/attachments_controller.rb
Colin Darie 44578ba65c fix(attachment): keep direct_upload behavior in poll url
Co-Authored-By: Christophe Robillard <christophe.robillard@beta.gouv.fr>
2023-09-22 10:24:16 +02:00

31 lines
858 B
Ruby

class AttachmentsController < ApplicationController
before_action :authenticate_logged_user!
include ActiveStorage::SetBlob
def show
@attachment = @blob.attachments.find(params[:id])
@user_can_edit = cast_bool(params[:user_can_edit])
@direct_upload = cast_bool(params[:direct_upload])
@view_as = params[:view_as]&.to_sym
@auto_attach_url = params[:auto_attach_url]
respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_url) }
end
end
def destroy
@attachment = @blob.attachments.find(params[:id])
@attachment.purge_later
flash.notice = 'La pièce jointe a bien été supprimée.'
@champ_id = params[:champ_id]
respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_url) }
end
end
end