From e233d90197bc70ef7775c364f3bdb13e2c6673a1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 12:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7=E5=92=8C?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=88=A0=E9=99=A4=E5=85=B3=E8=81=94=E4=B8=BA?= =?UTF-8?q?delete=5Fall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 10 +++++----- app/models/poll_answer.rb | 2 +- app/models/poll_question.rb | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 1cead3291..f72239ba7 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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)} diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb index 423198bbf..8e2421328 100644 --- a/app/models/poll_answer.rb +++ b/app/models/poll_answer.rb @@ -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)} #根据传入的参数查找问题 diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb index 1fc8e0c16..a0854aa48 100644 --- a/app/models/poll_question.rb +++ b/app/models/poll_question.rb @@ -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)}