Sha256: fa6725053684a210fbf1bf1f0bc7567ecc6014e7f848150aee7f948675c30236

Contents?: true

Size: 610 Bytes

Versions: 34

Compression:

Stored size: 610 Bytes

Contents

require "traits/taggable"
require "safe_html"

class CuratedList
  include Mongoid::Document
  include Mongoid::Timestamps

  include Taggable
  stores_tags_for :sections

  field "slug", type: String
  has_and_belongs_to_many :artefacts, class_name: "Artefact"

  index "slug"

  validates :slug, presence: true, uniqueness: true, slug: true

  def self.find_by_slug(slug)
    where(slug: slug).first
  end

  # Returns the artefacts in order, skipping missing artefacts
  def artefacts
    Artefact.where(:_id.in => artefact_ids).sort_by do |artefact|
      artefact_ids.index(artefact.id)
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
govuk_content_models-34.0.0 app/models/curated_list.rb
govuk_content_models-33.0.0 app/models/curated_list.rb
govuk_content_models-32.3.1 app/models/curated_list.rb
govuk_content_models-32.3.0 app/models/curated_list.rb
govuk_content_models-32.2.0 app/models/curated_list.rb
govuk_content_models-32.1.0 app/models/curated_list.rb
govuk_content_models-32.0.0 app/models/curated_list.rb
govuk_content_models-31.4.0 app/models/curated_list.rb
govuk_content_models-31.3.0 app/models/curated_list.rb
govuk_content_models-31.2.2 app/models/curated_list.rb
govuk_content_models-31.2.1 app/models/curated_list.rb
govuk_content_models-31.2.0 app/models/curated_list.rb
govuk_content_models-31.1.0 app/models/curated_list.rb
govuk_content_models-31.0.0 app/models/curated_list.rb
govuk_content_models-30.0.0 app/models/curated_list.rb
govuk_content_models-29.1.2 app/models/curated_list.rb
govuk_content_models-29.1.1 app/models/curated_list.rb
govuk_content_models-29.1.0 app/models/curated_list.rb
govuk_content_models-29.0.1 app/models/curated_list.rb
govuk_content_models-29.0.0 app/models/curated_list.rb