From 5d1ce5a656bf72d3acb35c13d7b4fcfb25801ad6 Mon Sep 17 00:00:00 2001 From: Tomas Costantino Date: Tue, 9 Dec 2025 11:07:22 +0100 Subject: [PATCH] rename from sibling_columns to surroundings --- app/models/column.rb | 7 +------ app/models/column/positioned.rb | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/column.rb b/app/models/column.rb index 0ff36a3b6..4c8358871 100644 --- a/app/models/column.rb +++ b/app/models/column.rb @@ -6,10 +6,5 @@ class Column < ApplicationRecord has_many :cards, dependent: :nullify after_save_commit -> { cards.touch_all }, if: -> { saved_change_to_name? || saved_change_to_color? } - after_create_commit -> { sibling_columns.touch_all } - after_destroy_commit -> { board.cards.touch_all; sibling_columns.touch_all } - - def sibling_columns - board.columns.where.not(id:).sorted - end + after_destroy_commit -> { board.cards.touch_all } end diff --git a/app/models/column/positioned.rb b/app/models/column/positioned.rb index 8518172de..ede57d139 100644 --- a/app/models/column/positioned.rb +++ b/app/models/column/positioned.rb @@ -5,6 +5,8 @@ module Column::Positioned scope :sorted, -> { order(position: :asc) } before_create :set_position + after_create_commit -> { surroundings.touch_all } + after_destroy_commit -> { surroundings.touch_all } end def move_left @@ -31,6 +33,10 @@ module Column::Positioned right_column.nil? end + def surroundings + board.columns.where(id: [ left_column&.id, right_column&.id ].compact) + end + private def set_position max_position = board.columns.maximum(:position) || 0