Sha256: 02c433333d378e179c5559c76bb235a69ff81328f7bc8f4508604fd56d3ea790

Contents?: true

Size: 773 Bytes

Versions: 9

Compression:

Stored size: 773 Bytes

Contents

require_dependency 'avo/application_controller'

module Avo
  class AttachmentsController < ApplicationController
    before_action :set_resource_name, only: :destroy
    before_action :set_resource, only: :destroy
    before_action :set_model, only: :destroy

    def show
    end

    def destroy
      blob = ActiveStorage::Blob.find(params[:signed_attachment_id])
      attachment = blob.attachments.find_by record_id: params[:id], record_type: @model.class.to_s

      if attachment.present?
        attachment.destroy

        redirect_to params[:referrer] || resource_path(@model), notice: t('avo.attachment_destroyed')
      else
        redirect_back fallback_location: resource_path(@model), notice: t('avo.failed_to_find_attachment')
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-0.5.0.beta9 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta8 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta7 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta6 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta5 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta4 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta3 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta2 app/controllers/avo/attachments_controller.rb
avo-0.5.0.beta1 app/controllers/avo/attachments_controller.rb