Sha256: 2f7cd6a847531e641ecfcedd23bad08942afb54f0fbc80774d939e3c55671057

Contents?: true

Size: 820 Bytes

Versions: 18

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module Spree::Taxon::PaperclipAttachment
  extend ActiveSupport::Concern

  included do
    has_attached_file :icon,
      styles: Spree::Config.taxon_image_styles,
      default_style: Spree::Config.taxon_image_style_default,
      url: '/spree/taxons/:id/:style/:basename.:extension',
      path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
      default_url: '/assets/default_taxon.png'

    validates_attachment :icon,
      content_type: { content_type: Spree::Config.allowed_image_mime_types }
  end

  def icon_present?
    icon.present?
  end

  def destroy_attachment(definition)
    return false unless respond_to?(definition)

    attached_file = send(definition)
    return false unless attached_file.exists?

    attached_file.destroy && save
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
solidus_core-4.4.1 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.4.0 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.3.4 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.2.4 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.5 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.3.3 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.3.2 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.4 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.3.1 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.3.0 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.2.3 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.3 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.2 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.2.2 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.2.1 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.2.0 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.1 app/models/spree/taxon/paperclip_attachment.rb
solidus_core-4.1.0 app/models/spree/taxon/paperclip_attachment.rb