From 26f850067125f4302c0c2cdf5a1bd794129bc61e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 22 Jan 2016 18:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=9B=9E=E5=A4=8D=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E8=AF=A5=E5=8D=9A=E5=AE=A2=E7=9A=84=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=BA=E5=BD=93=E5=89=8D=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 1 + app/models/blog_comment.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index df6ba10d2..87bbcb2f3 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -127,6 +127,7 @@ class BlogCommentsController < ApplicationController @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] @article.children << @blogComment @article.save + # @article.update_attribute(:updated_on, @blogComment.updated_on) @user_activity_id = params[:user_activity_id] user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first if user_activity diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index db28e55d6..2b31af604 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -18,6 +18,7 @@ class BlogComment < ActiveRecord::Base after_save :add_user_activity after_update :update_activity + after_create :update_parent_time before_destroy :destroy_user_activity scope :like, lambda {|arg| @@ -64,6 +65,11 @@ class BlogComment < ActiveRecord::Base (user && user.logged? && (self.author == user) ) || user.admin? end + def update_parent_time + if !self.parent.nil? + self.root.update_attribute(:updated_on, self.updated_on) + end + end def project end end