项目动态和组织动态删除后,删除相应的组织动态

This commit is contained in:
ouyangxuhua 2015-11-20 17:42:43 +08:00
parent a57260aae6
commit 6068867670
2 changed files with 8 additions and 3 deletions

View File

@ -6,7 +6,7 @@ class CourseActivity < ActiveRecord::Base
belongs_to :user belongs_to :user
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
after_save :add_user_activity, :add_course_activity 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 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 = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'")
user_activity.destroy_all user_activity.destroy_all
end 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 end

View File

@ -21,7 +21,7 @@ class ForgeActivity < ActiveRecord::Base
validates :forge_act_type, presence: true validates :forge_act_type, presence: true
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
after_save :add_user_activity, :add_org_activity 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 def add_user_activity
@ -67,7 +67,7 @@ class ForgeActivity < ActiveRecord::Base
end end
def destroy_org_activity 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 org_acts.destroy_all
end end
end end