|
|
|
@ -17,6 +17,7 @@ class BlogComment < ActiveRecord::Base
|
|
|
|
|
safe_attributes 'title', 'content',"sticky", "locked"
|
|
|
|
|
|
|
|
|
|
after_save :add_user_activity
|
|
|
|
|
after_update :update_activity
|
|
|
|
|
before_destroy :destroy_user_activity
|
|
|
|
|
|
|
|
|
|
scope :like, lambda {|arg|
|
|
|
|
@ -28,6 +29,15 @@ class BlogComment < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#动态更新
|
|
|
|
|
def update_activity
|
|
|
|
|
user_activity = UserActivity.where("act_type='BlogComment' and act_id =?",self.id).first
|
|
|
|
|
if user_activity
|
|
|
|
|
user_activity.updated_at = Time.now
|
|
|
|
|
user_activity.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#在个人动态里面增加当前动态
|
|
|
|
|
def add_user_activity
|
|
|
|
|
if self.parent_id.nil? #只有发博文才插入动态
|
|
|
|
|