aboutsummaryrefslogtreecommitdiff
blob: 16ca9ac9030b7267a8484eefb33039a98b45eaf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Question < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    title         :string
    content       :text
    documentation :string
    timestamps
  end

  validates_presence_of :title, :content
  #allow empty documentation and no category
  #maybe add a page for not complete questions

  belongs_to  :question_category
  has_many    :answers
  include Permissions::AnyoneCanViewAdminCanChange

  def answered?(user)
    user.signed_up? && user.answered_questions.include?(self)
  end

  def answer_of(user)
    answers.owner_is(user).first
  end
end