From 6068867670c33f9868001537c252cb58baa530d4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 17:42:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E5=92=8C?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81=E5=88=A0=E9=99=A4=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E7=9B=B8=E5=BA=94=E7=9A=84=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_activity.rb | 7 ++++++- app/models/forge_activity.rb | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index cd3234196..e1f9ab9f5 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -6,7 +6,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act after_save :add_user_activity, :add_course_activity - before_destroy :destroy_user_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -55,4 +55,9 @@ class CourseActivity < ActiveRecord::Base user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'") + org_activity.destroy_all + end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 5005f9eab..bb5f30442 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -21,7 +21,7 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act after_save :add_user_activity, :add_org_activity - before_destroy :destroy_user_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -67,7 +67,7 @@ class ForgeActivity < ActiveRecord::Base end def destroy_org_activity - org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") + org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and org_act_id = '#{self.forge_act_id}'") org_acts.destroy_all end end