19 lines
593 B
Ruby
19 lines
593 B
Ruby
class ChallengeChoose < ActiveRecord::Base
|
||
# attr_accessible :title, :body
|
||
# category 1 单选, 2,多选
|
||
# standard_answer 正确答案 answer: 答题的思路
|
||
default_scope :order => 'position'
|
||
belongs_to :challenge
|
||
has_many :challenge_tags, :dependent => :destroy
|
||
has_many :challenge_questions, :dependent => :destroy
|
||
has_one :choose_outputs, :dependent => :destroy
|
||
|
||
validates_presence_of :subject
|
||
|
||
# 判断当前用户是否答题
|
||
def current_choose_outputs
|
||
ChooseOutputs.where(:challenge_choose_id => self.id, :user_id => User.current.id).first
|
||
end
|
||
|
||
end
|