demarches-normaliennes/app/controllers/attachments_controller.rb

26 lines
672 B
Ruby
Raw Normal View History

class AttachmentsController < ApplicationController
before_action :authenticate_logged_user!
include ActiveStorage::SetBlob
def show
@attachment = @blob.attachments.find(params[:id])
@user_can_upload = params[:user_can_upload]
respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_url) }
end
end
2019-05-29 12:05:28 +02:00
def destroy
@attachment = @blob.attachments.find(params[:id])
@attachment.purge_later
flash.notice = 'La pièce jointe a bien été supprimée.'
respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_url) }
end
2019-05-29 12:05:28 +02:00
end
end