Sha256: 9ba94c8e1d7e3ce9adaddc65442cd223af10b49be1e941bfe0a2554ed7653b75

Contents?: true

Size: 582 Bytes

Versions: 8

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Categories serve as a taxonomy for attachments to use for while in the
  # context of a participatory space.
  class AttachmentCollection < ApplicationRecord
    include Decidim::TranslatableResource

    translatable_fields :name, :description
    belongs_to :collection_for, polymorphic: true
    has_many :attachments, foreign_key: "attachment_collection_id", class_name: "Decidim::Attachment", dependent: :nullify

    default_scope { order(arel_table[:weight].asc) }

    def unused?
      attachments.empty?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/models/decidim/attachment_collection.rb
decidim-core-0.23.5 app/models/decidim/attachment_collection.rb
decidim-core-0.23.4 app/models/decidim/attachment_collection.rb
decidim-core-0.23.3 app/models/decidim/attachment_collection.rb
decidim-core-0.23.2 app/models/decidim/attachment_collection.rb
decidim-core-0.23.1 app/models/decidim/attachment_collection.rb
decidim-core-0.23.1.rc1 app/models/decidim/attachment_collection.rb
decidim-core-0.23.0 app/models/decidim/attachment_collection.rb