You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/models/challenge_choose.rb

20 lines
706 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
#has_many :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