Sha256: 8595f59f6eafaf5532bbea438066689402ab216d218681327f460d9536c19ad9

Contents?: true

Size: 462 Bytes

Versions: 12

Compression:

Stored size: 462 Bytes

Contents

class Answer < ActiveRecord::Base
  
  # Associations
  belongs_to :question
  has_many :responses

  # Scopes
  default_scope :order => "display_order ASC"
  
  # Validations
  validates_presence_of :text
  validates_numericality_of :question_id, :allow_nil => false, :only_integer => true
  
  # Methods
  def renderer(q = question)  
    r = [q.pick.to_s, self.response_class].compact.map(&:downcase).join("_")
    r.blank? ? :default : r.to_sym
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
surveyor-0.9.10 app/models/answer.rb
surveyor-0.9.9 app/models/answer.rb
surveyor-0.9.8 app/models/answer.rb
surveyor-0.9.7 app/models/answer.rb
surveyor-0.9.6 app/models/answer.rb
surveyor-0.9.5 app/models/answer.rb
surveyor-0.9.4 app/models/answer.rb
surveyor-0.9.3 app/models/answer.rb
surveyor-0.9.2 app/models/answer.rb
surveyor-0.9.1 app/models/answer.rb
surveyor-0.9.0 app/models/answer.rb
surveyor-0.8.0 app/models/answer.rb