From cb9e4815849630cad0aa72fb9ca563b0fb38c729 Mon Sep 17 00:00:00 2001 From: IkumaTadokoro Date: Wed, 10 Nov 2021 15:45:15 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D?= =?UTF-8?q?=E3=81=8C`*comment=5Fat`=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E7=AE=87=E6=89=80=E3=82=92=E3=80=81`*comment?= =?UTF-8?q?ed=5Fat`=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment_callbacks.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 0a19ee9a7c1..2db4f509f52 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -11,7 +11,7 @@ def after_create(comment) return unless comment.commentable.instance_of?(Product) - update_last_comment_at(comment) + update_last_commented_at(comment) update_commented_at(comment) delete_product_cache(comment.commentable.id) end @@ -19,29 +19,29 @@ def after_create(comment) def after_update(comment) return unless comment.commentable.instance_of?(Product) - update_last_comment_at(comment) + update_last_commented_at(comment) update_commented_at(comment) end def after_destroy(comment) return unless comment.commentable.instance_of?(Product) - delete_last_comment_at(comment.commentable.id) + delete_last_commented_at(comment.commentable.id) delete_commented_at(comment) delete_product_cache(comment.commentable.id) end private - def reset_last_comment_at(product) + def reset_last_commented_at(product) product.mentor_last_commented_at = nil product.self_last_commented_at = nil end - def delete_last_comment_at(product_id) + def delete_last_commented_at(product_id) product = Product.find(product_id) - reset_last_comment_at(product) + reset_last_commented_at(product) product.comments.each do |comment| if comment.user.mentor @@ -53,7 +53,7 @@ def delete_last_comment_at(product_id) product.save! end - def update_last_comment_at(comment) + def update_last_commented_at(comment) product = Product.find(comment.commentable.id) if comment.user.mentor product.mentor_last_commented_at = comment.updated_at