30 lines
826 B
Ruby
30 lines
826 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])
|
|
@user_can_download = cast_bool(params[:user_can_download])
|
|
@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
|