Sha256: 096144706adc0a5dba9793961a77deabf8f914455116e09fb0e9e303e251c830
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
class Question < ActiveRecord::Base require 'acts_as_list' TYPES = ['TextQuestion', 'EssayQuestion', 'ChooseOneQuestion', 'ChecklistQuestion', 'FormSection'] belongs_to :asker, :polymorphic => true has_many :choices, :dependent => :destroy has_many :answers, :dependent => :destroy acts_as_list :scope=>:asker attr_accessible :type, :name, :instructions, :required, :choices_attributes, :position accepts_nested_attributes_for :choices, :allow_destroy=>true, :reject_if=>lambda{|attrs| attrs['name'].blank? } validates_presence_of :type, :name validates_inclusion_of :type, :in=>TYPES default_scope :order => :position scope :required, where(:required => true) def attributes_protected_by_default default = [ self.class.primary_key ] default << 'id' unless self.class.primary_key.eql? 'id' default end def rhetorical? false end def supports_choices false end def choice_names return [] unless supports_choices self.choices.map(&:name) end def supports_multiple_answers? false end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ask-0.4.1 | app/models/question.rb |
ask-0.4.0 | app/models/question.rb |
ask-0.3.1 | app/models/question.rb |
ask-0.3.0 | app/models/question.rb |
ask-0.2.0 | app/models/question.rb |