Finished phase005
This commit is contained in:
@@ -3,7 +3,7 @@ class Vehicle < ApplicationRecord
|
||||
has_many :fuel_entries, dependent: :restrict_with_error
|
||||
has_many :maintenance_entries, dependent: :restrict_with_error
|
||||
|
||||
before_validation :normalize_vin
|
||||
before_validation :normalize_vin, :normalize_licence_plate
|
||||
|
||||
validates :make, :model, :color, :vin, :licence_plate, presence: true
|
||||
validates :vin, uniqueness: true
|
||||
@@ -19,4 +19,8 @@ class Vehicle < ApplicationRecord
|
||||
def normalize_vin
|
||||
self.vin = vin.to_s.strip.upcase if vin.present?
|
||||
end
|
||||
|
||||
def normalize_licence_plate
|
||||
self.licence_plate = licence_plate.to_s.strip.upcase if licence_plate.present?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user