Sha256: 048a85451e1de074ef73febde91ae73ff20bc97747c4dbe5f2feffc345cc9c45
Contents?: true
Size: 782 Bytes
Versions: 4
Compression:
Stored size: 782 Bytes
Contents
module Helena class SubQuestion include Helena::Concerns::ApplicationModel include Mongoid::Orderable field :text, type: String field :value, type: String field :code, type: String field :preselected, type: Boolean embedded_in :question, inverse_of: :sub_questions orderable validate :uniqueness_of_code validates :text, presence: true, uniqueness: true def splitted? parts.size > 1 end def parts text.split '|' end def uniqueness_of_code return unless question question_code_occurences = question.question_group.version.question_code_occurences return true if question_code_occurences[code] <= 1 errors.add(:code, :taken, value: code) end end end
Version data entries
4 entries across 4 versions & 1 rubygems