项目动态和组织动态删除后,删除相应的组织动态
This commit is contained in:
parent
a57260aae6
commit
6068867670
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue