Skip to content

Commit

Permalink
update discussion replacing deprecated attr_changed? with save_change…
Browse files Browse the repository at this point in the history
…_to_attr? and (#373)
  • Loading branch information
yuenmichelle1 authored Sep 30, 2024
1 parent b5c844f commit 1c36ce3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/discussion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c36ce3

Please sign in to comment.