Sha256: 9e6d344826c1ba1e3cfcc8b35bced552632b7dea8b8b5ba1eb00b80de5083e89

Contents?: true

Size: 773 Bytes

Versions: 34

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

34 entries across 34 versions & 1 rubygems

Version Path
avo-1.3.5 app/controllers/avo/attachments_controller.rb
avo-1.3.4 app/controllers/avo/attachments_controller.rb
avo-1.3.3 app/controllers/avo/attachments_controller.rb
avo-1.3.2 app/controllers/avo/attachments_controller.rb
avo-1.3.1 app/controllers/avo/attachments_controller.rb
avo-1.3.0 app/controllers/avo/attachments_controller.rb
avo-1.2.11.pre.4 app/controllers/avo/attachments_controller.rb
avo-1.2.11.pre.3 app/controllers/avo/attachments_controller.rb
avo-1.2.11.pre.2 app/controllers/avo/attachments_controller.rb
avo-1.2.11.pre.1 app/controllers/avo/attachments_controller.rb
avo-1.2.10 app/controllers/avo/attachments_controller.rb
avo-1.2.9 app/controllers/avo/attachments_controller.rb
avo-1.2.8 app/controllers/avo/attachments_controller.rb
avo-1.2.7 app/controllers/avo/attachments_controller.rb
avo-1.2.6 app/controllers/avo/attachments_controller.rb
avo-1.2.6.pre.1 app/controllers/avo/attachments_controller.rb
avo-1.2.5 app/controllers/avo/attachments_controller.rb
avo-1.2.4 app/controllers/avo/attachments_controller.rb
avo-1.2.3 app/controllers/avo/attachments_controller.rb
avo-1.3.0.pre.1 app/controllers/avo/attachments_controller.rb