Make stuff sortable

This commit is contained in:
david 2024-11-11 04:04:13 +01:00
parent 50e853098b
commit ee5dbcf33e
21 changed files with 161 additions and 28 deletions

View file

@ -7,6 +7,7 @@ class ChecklistEntry < ApplicationRecord
before_validation :set_position
before_update :update_positions, if: :position_changed?
private
def set_position
self.position ||= (checklist.checklist_entries.pluck(:position).max || 0) + 1
end