Sha256: ad7e9676b1958c6dc87739b7b0307ecc1a4a05b2f4fcf1c67df295f6183399c1
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module ActiveRecordSurvey class InstanceNode < ::ActiveRecord::Base self.table_name = "active_record_survey_instance_nodes" belongs_to :instance, :class_name => "ActiveRecordSurvey::Instance", :foreign_key => :active_record_survey_instance_id belongs_to :node, :class_name => "ActiveRecordSurvey::Node", :foreign_key => :active_record_survey_node_id validates_presence_of :instance validate do |instance_node| # This instance_node has no valid path to the root node if !self.node.instance_node_path_to_root?(self) instance_node.errors[:base] << "NO_PATH" end # Two instance_nodes on the same node for this instance if self.instance.instance_nodes.select { |i| # Two votes share a parent (this means a question has two answers for this instance) (i.node.node_maps.collect { |j| j.parent } & self.node.node_maps.collect { |j| j.parent }).length > 0 }.length > 1 instance_node.errors[:base] << "DUPLICATE_PATH" end if !self.node.validate_instance_node(self) instance_node.errors[:base] << "INVALID" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record_survey-0.1.6 | lib/active_record_survey/instance_node.rb |