Sha256: 938e0822e38b8829cba1a9ca21e058bc71b5c47c82c84da55f18159cc4d6a7b3
Contents?: true
Size: 615 Bytes
Versions: 6
Compression:
Stored size: 615 Bytes
Contents
module Cmor::Blog class AssetDetail < ApplicationRecord belongs_to :post belongs_to :asset, class_name: 'ActiveStorage::Attachment', dependent: :destroy acts_as_list scope: :post_id # acts as published include ActsAsPublished::ActiveRecord acts_as_published scope :images, -> { joins(asset: [:blob]).where("active_storage_blobs.content_type LIKE '%image/%'") } scope :non_images, -> { joins(asset: [:blob]).where("active_storage_blobs.content_type NOT LIKE '%image/%'") } def filename asset&.blob&.filename end def human filename end end end
Version data entries
6 entries across 6 versions & 1 rubygems