Sha256: 8c2e4159bca39d8b13ac6c0da6bed1bb11a1b6ecc8b0c7ad415fb82dd70c02bc

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 Bytes

Contents

module Spree
  class Attachment < Spree::Asset
    ATTACHMENT_ATTRIBUTES = %i[alt attachment_content_type attachment_file_name
                               attachment_updated_at id position type].freeze
    PERMITTED_ATTACHMENT_ATTRIBUTES = %i[alt attachment position viewable_id viewable_type].freeze

    has_attached_file :attachment

    validate :no_attachment_errors
    validates_attachment :attachment, content_type: { content_type: 'application/pdf' }

    def no_attachment_errors
      errors.add :attachment, "Paperclip returned errors for file #{attachment_file_name}" if attachment.errors.any?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_product_attachments-0.0.4 app/models/spree/attachment.rb
solidus_product_attachments-0.0.2 app/models/spree/attachment.rb
solidus_product_attachments-0.0.1 app/models/spree/attachment.rb