Finished phase006
CI / scan_ruby (push) Failing after 7s
CI / scan_js (push) Failing after 7s
CI / lint (push) Failing after 8s

This commit is contained in:
2026-09-16 16:37:03 -06:00
parent 0826d267f2
commit 87d2141ed0
22 changed files with 754 additions and 10 deletions
+14
View File
@@ -4,4 +4,18 @@ class MaintenanceSchedule < ApplicationRecord
validates :maintenance_type, presence: true, uniqueness: { scope: :vehicle_id, case_sensitive: false }
validates :mileage_interval, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :time_interval, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :baseline_odometer, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :baseline_date, presence: true
validates :active, inclusion: { in: [ true, false ] }
validate :baseline_date_cannot_be_in_the_future
scope :active, -> { where(active: true) }
private
def baseline_date_cannot_be_in_the_future
return if baseline_date.blank? || baseline_date <= Date.current
errors.add(:baseline_date, "can't be in the future")
end
end