class SurveyQuestion Oneline = 0 Multiline = 1 Radio = 2 Check = 3 Select = 4 Radiogroup = 5 include Mongoid::Document field :title, :localize => true field :description, :localize => true field :is_required, :type => Boolean field :type, :type => Integer # allow custom answer option field :custom_option, :type => Boolean field :sequence, :type => Integer, :default => 0 belongs_to :survey embeds_many :survey_question_options embeds_many :survey_question_radiogroups accepts_nested_attributes_for :survey_question_options, :allow_destroy => true accepts_nested_attributes_for :survey_question_radiogroups, :allow_destroy => true default_scope asc(:sequence) def jumpable? case type when SurveyQuestion::Radio, SurveyQuestion::Select true else false end end def can_set_jump? ( !custom_option ) end def get_jump_tos Hash[survey_question_options.select{ |o| !o.jump_to.blank? }.collect{ |o| [o.id.to_s, o.jump_to] }] end end