aboutsummaryrefslogtreecommitdiff
blob: f721d2fe0ab9a6bdd951606e95b07b3e4d77f34c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'permissions/inherit.rb'
class QuestionContentMultipleChoice < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    content   HoboFields::MarkdownString, :null => false
    timestamps
  end

  belongs_to            :question, :null => false
  attr_readonly         :question
  has_many              :options, :as => :option_owner, :accessible => true, :uniq => true
  validates_length_of   :content, :minimum => 2

  inherit_permissions(:question)

  def new_answer_of(user)
    MultipleChoiceAnswer.new :question_id => question_id, :owner => user
  end
end