Create vehicle.rb

This commit is contained in:
2017-06-13 12:22:48 -04:00
committed by GitHub
parent 7ca3315ce5
commit 7ced1bf942

View File

@@ -72,7 +72,7 @@ class Vehicle < ActiveRecord::Base
# Force Upper Case for VIN numbers
def vin=(val)
val = val.to_s.gsub!(/[^[A-HJ-NPR-Za-hj-npr-z\d]{8}]/,'')
val = val.to_s.gsub!(/[A-HJ-NPR-Za-hj-npr-z\d]/,'')
# The to_s is in case you get nil/non-string
write_attribute(:vin, val.to_s.upcase)