parent
6f900946d7
commit
2a01019457
@ -1,9 +1,16 @@
|
|||||||
class ExerciseChoice < ApplicationRecord
|
class ExerciseChoice < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :exercise_question
|
belongs_to :exercise_question
|
||||||
has_many :exercise_answers, :dependent => :destroy
|
has_many :exercise_answers
|
||||||
has_many :exercise_standard_answers, :dependent => :destroy
|
has_many :exercise_standard_answers
|
||||||
|
|
||||||
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
|
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
|
||||||
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
|
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
|
||||||
|
|
||||||
|
after_destroy :destroy_choices_relations
|
||||||
|
|
||||||
|
def destroy_choices_relations
|
||||||
|
exercise_answers.destroy_all
|
||||||
|
exercise_standard_answers.destroy_all
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in new issue