Finished phase005
CI / scan_ruby (push) Failing after 1m5s
CI / scan_js (push) Failing after 6s
CI / lint (push) Failing after 1m29s

This commit is contained in:
2026-09-16 15:34:50 -06:00
parent a3a65c24ed
commit 0826d267f2
38 changed files with 1596 additions and 9 deletions
+8
View File
@@ -7,6 +7,7 @@ class FuelEntry < ApplicationRecord
validates :price_paid, presence: true, numericality: { greater_than: 0 }
validates :date, presence: true
validate :date_cannot_be_in_the_future
validate :odometer_cannot_be_less_than_vehicle_current_odometer
private
@@ -15,4 +16,11 @@ class FuelEntry < ApplicationRecord
errors.add(:date, "can't be in the future")
end
def odometer_cannot_be_less_than_vehicle_current_odometer
return if vehicle.blank? || odometer.blank?
return if odometer >= vehicle.current_odometer
errors.add(:odometer, "cannot be less than the vehicle's current odometer")
end
end