修改试卷和问卷删除关联为delete_all

dev_forum
SylorHuang 5 years ago
parent 7a007dbd44
commit e233d90197

@ -4,13 +4,13 @@ class Poll < ApplicationRecord
belongs_to :exercise_bank, optional: true
# belongs_to :exercise_bank
has_many :poll_questions,dependent: :destroy
has_many :poll_users, :dependent => :destroy
has_many :poll_questions,dependent: :delete_all
has_many :poll_users, :dependent => :delete_all
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
has_many :poll_group_settings, :dependent => :destroy
has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy
has_many :poll_group_settings, :dependent => :delete_all
has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :delete_all
has_many :tidings, as: :container, dependent: :destroy
has_many :tidings, as: :container, dependent: :delete_all
scope :publish_or_not, -> { where("polls_status > ? ",1)}
scope :only_public, -> {where("is_public = ?",true)}

@ -3,7 +3,7 @@ class PollAnswer < ApplicationRecord
# include Redmine::SafeAttributes
belongs_to :poll_question
has_many :poll_votes, :dependent => :destroy
has_many :poll_votes, :dependent => :delete_all
scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题
scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题

@ -1,9 +1,9 @@
class PollQuestion < ApplicationRecord
belongs_to :poll
has_many :poll_answers, :dependent => :destroy
has_many :poll_answers, :dependent => :delete_all
attr_accessor :question_answers, :question_other_anser
has_many :poll_votes, :dependent => :destroy
has_many :poll_votes
scope :ques_count, lambda {|k| where("question_type = ?",k)}
scope :ques_necessary, -> {where("is_necessary = ?",1)}

Loading…
Cancel
Save