Sha256: a2eeb7f1169a91816c342710a3c55abe856d64a5791df674c6a1d6d3152827ad

Contents?: true

Size: 701 Bytes

Versions: 6

Compression:

Stored size: 701 Bytes

Contents

class Dorsale::Alexandrie::Attachment < ::Dorsale::ApplicationRecord
  self.table_name = "dorsale_alexandrie_attachments"

  belongs_to :attachable, polymorphic: true
  belongs_to :sender, class_name: User

  belongs_to :attachment_type, required: false

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

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

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

  private

  before_save :assign_default_name

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dorsale-3.10.3 app/models/dorsale/alexandrie/attachment.rb
dorsale-3.10.2 app/models/dorsale/alexandrie/attachment.rb
dorsale-3.10.1 app/models/dorsale/alexandrie/attachment.rb
dorsale-3.10.0 app/models/dorsale/alexandrie/attachment.rb
dorsale-3.9.8 app/models/dorsale/alexandrie/attachment.rb
dorsale-3.9.7 app/models/dorsale/alexandrie/attachment.rb