Sha256: fbae88c703b4f57682117ccb2fd172a185f69e8a4942c50f5775b90ba47bd7dd

Contents?: true

Size: 524 Bytes

Versions: 33

Compression:

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

    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

33 entries across 33 versions & 1 rubygems

Version Path
cmor_blog-0.0.35.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.34.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.33.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.32.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.31.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.30.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.29.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.28.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.27.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.26.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.25.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.24.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.22.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.21.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.20.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.19.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.18.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.17.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.15.pre app/models/cmor/blog/asset_detail.rb
cmor_blog-0.0.14.pre app/models/cmor/blog/asset_detail.rb