Sha256: 6433225f5fb236f8b7180b78cae460357035ff4b6831f03f36344796470ba4f0

Contents?: true

Size: 558 Bytes

Versions: 5

Compression:

Stored size: 558 Bytes

Contents

module Kuhsaft
  class Asset < ActiveRecord::Base
    scope :by_date, -> { order('updated_at DESC') }
    mount_uploader :file, Kuhsaft::AssetUploader

    def file_type
      return unless file.path.present?

      ext = File.extname(file.path).split('.').last
      ext.to_sym if ext.present?
    end

    def name
      File.basename(file.path) if file.present? && file.path.present?
    end

    def path
      file.url
    end

    def path=(val)
      # do nothing
    end

    def filename
      try(:file).try(:file).try(:filename)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kuhsaft-2.3.4 app/models/kuhsaft/asset.rb
kuhsaft-2.3.3 app/models/kuhsaft/asset.rb
kuhsaft-2.3.2 app/models/kuhsaft/asset.rb
kuhsaft-2.3.1 app/models/kuhsaft/asset.rb
kuhsaft-2.3.0 app/models/kuhsaft/asset.rb