|
|
@ -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
|
|
|
|