From 6977131cb1b0e627f4e1446fad956752baf46174 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Wed, 25 Sep 2024 14:34:31 -0500 Subject: [PATCH] update discussion replacing deprecated attr_changed? with save_change_to_attr? and --- app/models/discussion.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/discussion.rb b/app/models/discussion.rb index d7009048..a66fc4eb 100644 --- a/app/models/discussion.rb +++ b/app/models/discussion.rb @@ -25,7 +25,7 @@ class Discussion < ApplicationRecord before_create :denormalize_attributes before_save :clear_sticky, unless: ->{ sticky? } before_save :set_sticky_position, if: ->{ sticky? && sticky_position.nil? } - after_update :update_board_counters, if: ->{ board_id_changed? } + after_update :update_board_counters, if: ->{ saved_change_to_board_id? } moderatable_with :destroy, by: [:moderator, :admin] moderatable_with :ignore, by: [:moderator, :admin] @@ -70,7 +70,7 @@ def denormalize_attributes def update_board_counters comments.update_all board_id: board_id - changes.fetch(:board_id, []).compact.each do |id| + saved_changes.fetch(:board_id, []).compact.each do |id| Board.find_by_id(id).try :count_users_and_comments! end end