Removed squish_vin and added last 8 of vin to vehicle name

This commit is contained in:
2018-03-27 09:40:01 -04:00
parent 49858c45c9
commit 3509ae9725

View File

@@ -29,7 +29,8 @@ class Vehicle < ActiveRecord::Base
if year.nil? or make.nil? or model.nil?
return "#{vin}"
else
return "#{year} #{make} #{model}"
split_vin = vin.scan(/.{1,9}/)
return "#{year} #{make} #{model} - #{split_vin[1]}"
end
end
@@ -113,15 +114,4 @@ private
self.name = to_s
end
# makes a squishvin
# https://api.edmunds.com/api/vehicle/v2/squishvins/#{vin}/?fmt=json&api_key=#{ENV['edmunds_key']}
def vin_squish
if not self.vin? or self.vin.size < 11
# this is to go ahead and query the API, letting them handle the error. :P
return '1000000000A'
end
v = self.vin[0,11]
return v.slice(0,8) + v.slice(9,11)
end
end