Sha256: 30a5df7860903485f4e824b824a6775267f0808cf7cb65539d1c9e3d78c3aff8
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
module Headmin module Blob extend ActiveSupport::Concern included do class << self def not_attached_to_variant left_outer_joins(:attachments) .where.not(active_storage_attachments: {record_type: "ActiveStorage::VariantRecord"}) .or(is_orphan) end def is_orphan left_outer_joins(:attachments) .where(active_storage_attachments: {id: nil}) end def by_mimetypes_string(mimetype_string = "") by_mimetypes(mimetype_string.split(",")) end def by_mimetypes(mimetypes = []) results = self mimetypes.map.with_index do |mimetype, index| content_type = mimetype.tr("*", "%") query = where(arel_table[:content_type].matches(content_type)) results = index == 0 ? query : results.or(query) end results end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
headmin-0.5.7 | app/models/concerns/headmin/blob.rb |