Sha256: 4304599f6f74c0cdff8c4dfa60ffc8fd043e4b4d4e190944a8040365bb4f2960
Contents?: true
Size: 1.01 KB
Versions: 34
Compression:
Stored size: 1.01 KB
Contents
require "edition" class SimpleSmartAnswerEdition < Edition class Node include Mongoid::Document embedded_in :edition, :class_name => "SimpleSmartAnswerEdition" embeds_many :options, :class_name => "SimpleSmartAnswerEdition::Node::Option" accepts_nested_attributes_for :options, :allow_destroy => true field :slug, type: String field :title, type: String field :body, type: String field :order, type: Integer field :kind, type: String default_scope order_by([:order, :asc]) GOVSPEAK_FIELDS = [:body] KINDS = [ 'question', 'outcome' ] validates :title, :kind, presence: true validates :kind, inclusion: { :in => KINDS } validates :slug, :presence => true, :format => {:with => /\A[a-z0-9-]+\z/} validate :outcomes_have_no_options validates_with SafeHtml private def outcomes_have_no_options errors.add(:options, "cannot be added for an outcome") if options.present? and options.any? and kind == "outcome" end end end
Version data entries
34 entries across 34 versions & 1 rubygems