Sha256: 72abd44007c2397da84200fc15ac923e95a6a5ec30876207b67deb1968fcb9c8

Contents?: true

Size: 685 Bytes

Versions: 17

Compression:

Stored size: 685 Bytes

Contents

require "slug_validator"
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"

  GOVSPEAK_FIELDS = []

  validates :slug, presence: true, uniqueness: true, slug: true
  validates_with SafeHtml

  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

17 entries across 17 versions & 1 rubygems

Version Path
govuk_content_models-8.1.0 app/models/curated_list.rb
govuk_content_models-8.0.0 app/models/curated_list.rb
govuk_content_models-7.3.1 app/models/curated_list.rb
govuk_content_models-7.3.0 app/models/curated_list.rb
govuk_content_models-7.2.1 app/models/curated_list.rb
govuk_content_models-7.2.0 app/models/curated_list.rb
govuk_content_models-7.1.1 app/models/curated_list.rb
govuk_content_models-7.1.0 app/models/curated_list.rb
govuk_content_models-7.0.0 app/models/curated_list.rb
govuk_content_models-6.4.0 app/models/curated_list.rb
govuk_content_models-6.3.0 app/models/curated_list.rb
govuk_content_models-6.1.0 app/models/curated_list.rb
govuk_content_models-6.0.6 app/models/curated_list.rb
govuk_content_models-6.0.5 app/models/curated_list.rb
govuk_content_models-6.0.4 app/models/curated_list.rb
govuk_content_models-6.0.3 app/models/curated_list.rb
govuk_content_models-6.0.2 app/models/curated_list.rb