diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb
index c56412f..30181eb 100644
--- a/app/models/vehicle.rb
+++ b/app/models/vehicle.rb
@@ -58,10 +58,10 @@ class Vehicle < ActiveRecord::Base
end
# returns the number of doors of the vehicle
- def doors
- get_details if @details.nil?
- return @details.doors if @details
- end
+ #def doors
+ # get_details if @details.nil?
+ # return @details.doors if @details
+ #end
# Force Upper Case for make numbers
def make=(val)
@@ -93,8 +93,10 @@ class Vehicle < ActiveRecord::Base
if @details
begin
self.year = @details.year unless @details.year.nil?
- self.make = @details.make unless @details.make.nil?
- self.model = @details.model unless @details.model.nil?
+ self.make = @details.make unless @details.make.nil?
+ self.model = @details.model unless @details.model.nil?
+ self.doors = @details.doors unless @details.doors.nil?
+ self.trim = @details.trim unless @details.trim.nil?
rescue Exception => e
errors.add(:vin, e.message)
end
@@ -110,9 +112,9 @@ private
#validate the vin before calling a remote server
validation = NhtsaVin.validate(self.vin)
begin
- #if the vin validation failed, raise an exception and exit
- raise RuntimeError, validation.error unless validation.valid?
- # query NHTSA for details on the vin
+ #if the vin validation failed, raise an exception and exit
+ raise RuntimeError, validation.error unless validation.valid?
+ # query NHTSA for details on the vin
query = NhtsaVin.get(self.vin)
raise RuntimeError, query.error unless query.valid?
@details = query.response
diff --git a/app/views/vehicles/_details.html.erb b/app/views/vehicles/_details.html.erb
index dcb5e1d..0657dee 100644
--- a/app/views/vehicles/_details.html.erb
+++ b/app/views/vehicles/_details.html.erb
@@ -16,6 +16,10 @@
<%= @vin[0] if @vin %><%=@vin[1] if @vin%> |
+ <%= t(:label_trim) %> |
+ <%= vehicle.doors %> <%=t(:label_door)%> <%= vehicle.trim %> |
+
+
| <%= t(:field_notes) %> |
<%= vehicle.notes %> |
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d75732f..bbbe1cc 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -77,4 +77,6 @@ en:
label_no_estimates: "No Estimates"
label_no_invoices: "No Invoices"
label_invoices: "Invoices"
- label_load_customer: "Load Customer"
\ No newline at end of file
+ label_load_customer: "Load Customer"
+ label_door: "Door"
+ label_trim: "Trim"
\ No newline at end of file
diff --git a/db/migrate/033_update_vehicles_trim.rb b/db/migrate/033_update_vehicles_trim.rb
new file mode 100644
index 0000000..c94f05b
--- /dev/null
+++ b/db/migrate/033_update_vehicles_trim.rb
@@ -0,0 +1,30 @@
+#The MIT License (MIT)
+#
+#Copyright (c) 2022 rick barrette
+#
+#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+#
+#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+#
+#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+class UpdateVehiclesTrim < ActiveRecord::Migration[5.1]
+ def change
+ add_column :vehicles, :doors, :text
+ add_column :vehicles, :trim, :text
+
+ reversible do |direction|
+ direction.up {
+
+ # Update local vehicle database by forcing a save, look at before_save
+ vehicles = Vehicle.all
+ vehicles.each { |vehicle|
+ vehicle.save!
+ }
+
+ }
+ end
+
+ end
+
+end