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