Fix numbers autoincrement
All checks were successful
/ Run tests (push) Successful in 2m16s
/ Run system tests (push) Successful in 2m29s
/ Build, push and deploy image (push) Successful in 1m37s

This commit is contained in:
david 2024-09-12 01:18:04 +02:00
parent 63590c9e92
commit 1cdf5048c3
6 changed files with 16 additions and 5 deletions

View file

@ -52,7 +52,9 @@ class Check < ApplicationRecord
:standard_text,
:powerpoint_text
after_create { update(number: id) unless number }
validates :number, uniqueness: true, presence: true
before_validation { self.number = self.class.maximum(:id).to_i + 1 unless self.number.present? }
scope(:search, lambda { |term|
# TODO: Search only fields for current locale.