Files
fizzy/app/models/column.rb
T
David Heinemeier Hansson 966aa51a37 Get rid of unnecessary touch jobs
touch_all on 10K cards took 6ms in testing
2025-11-02 14:15:53 +01:00

19 lines
495 B
Ruby

class Column < ApplicationRecord
include Positioned
belongs_to :collection, touch: true
has_many :cards, dependent: :nullify
validates :name, presence: true
validates :color, presence: true
before_validation :set_default_color
after_save_commit -> { cards.touch_all }, if: -> { saved_change_to_name? || saved_change_to_color? }
after_destroy_commit -> { collection.cards.touch_all }
private
def set_default_color
self.color ||= Card::DEFAULT_COLOR
end
end