blob: cd1d277706eb164cfbf0bd16f4af8e3c405ee81c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
require 'permissions/inherit.rb'
# Multiple choice content for question.
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)
# Returns new answer (of proper class) of user for question (relation).
def new_answer_of(user)
MultipleChoiceAnswer.new :question_id => question_id, :owner => user
end
end
|