Sha256: f7baab2a10feecb7f73ef7a0e47df47cd2ee289da701867c1892f2e75c1a8823

Contents?: true

Size: 732 Bytes

Versions: 32

Compression:

Stored size: 732 Bytes

Contents

module Dorsale
  module Alexandrie
    class Attachment < ActiveRecord::Base
      self.table_name = "dorsale_alexandrie_attachments"

      belongs_to :attachable, polymorphic: true
      belongs_to :sender,     polymorphic: true

      validates :attachable, presence: true
      validates :file,       presence: true

      mount_uploader :file, ::Dorsale::Alexandrie::FileUploader

      before_save :set_default_name

      def set_default_name
        self.name = file_identifier if name.blank?
      end

      def download_filename
        if File.extname(file_identifier) == File.extname(name)
          name
        else
          name.parameterize + File.extname(file_identifier)
        end
      end

    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
dorsale-2.6.8 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.7 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.6 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.5 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.4 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.3 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.2 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.1 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.6.0 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.5.0 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.4.3 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.4.2 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.4.1 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.4.0 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.5 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.4 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.3 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.2 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.1 app/models/dorsale/alexandrie/attachment.rb
dorsale-2.3.0 app/models/dorsale/alexandrie/attachment.rb