Sha256: 279ae1e613cc8c8d95754a25b4f2daf4b2eb230296cf5c9ec937b68322d02b6b

Contents?: true

Size: 559 Bytes

Versions: 14

Compression:

Stored size: 559 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

14 entries across 14 versions & 2 rubygems

Version Path
kuhsaft-2.6.3 app/models/kuhsaft/asset.rb
kuhsaft-2.6.2 app/models/kuhsaft/asset.rb
kuhsaft-2.6.1 app/models/kuhsaft/asset.rb
kuhsaft-2.5.2 app/models/kuhsaft/asset.rb
kuhsaft-2.6.0 app/models/kuhsaft/asset.rb
kuhsaft-2.5.1 app/models/kuhsaft/asset.rb
kuhsaft-2.5.0 app/models/kuhsaft/asset.rb
qbrick-2.5.0.pre app/models/kuhsaft/asset.rb
kuhsaft-2.4.3 app/models/kuhsaft/asset.rb
kuhsaft-2.4.2 app/models/kuhsaft/asset.rb
kuhsaft-2.4.1 app/models/kuhsaft/asset.rb
kuhsaft-2.4.0 app/models/kuhsaft/asset.rb
kuhsaft-2.3.6 app/models/kuhsaft/asset.rb
kuhsaft-2.3.5 app/models/kuhsaft/asset.rb