Skip to content

Commit

Permalink
メソッド名が*comment_atになっている箇所を、*commented_atに修正
Browse files Browse the repository at this point in the history
  • Loading branch information
IkumaTadokoro committed Nov 10, 2021
1 parent 7dd88f2 commit cb9e481
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/models/comment_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ 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

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
Expand All @@ -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
Expand Down

0 comments on commit cb9e481

Please sign in to comment.