diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index a12b088..7a11cb4 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -64,6 +64,7 @@ class VehiclesController < ApplicationController @vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin @issues = @vehicle.issues.order(id: :desc) @closed_issues = (@issues - @issues.open) + flash[:error] = t :alert_no_customer if @vehicle.customer.nil? rescue flash[:error] = t :alert_vehicle_not_found render_404 diff --git a/app/views/vehicles/_details.html.erb b/app/views/vehicles/_details.html.erb index 1df3fb5..2875758 100644 --- a/app/views/vehicles/_details.html.erb +++ b/app/views/vehicles/_details.html.erb @@ -8,7 +8,7 @@ <%= t(:field_customer)%> - <%= link_to(vehicle.customer.name, customer_path(vehicle.customer)) if vehicle.customer %> + <%= vehicle.customer ? link_to(vehicle.customer.name, customer_path(vehicle.customer)) : t(:no_customer) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 3e8ec6d..0c06c40 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,7 @@ en: alert_vehicle_not_found: "Vehicle not found." alert_vehicle_not_deleted: "Vehicle could not be deleted." alert_vehicle_not_created: "Vehicle could not be created." - alert_vehicle_not_updated: "Vehicle could not be updated." \ No newline at end of file + alert_vehicle_not_updated: "Vehicle could not be updated." + no_customer: "Customer no longer exists" + alert_no_customer: "Customer no longer exists, check for merged customers or deleted customers in Quick Books Online." + \ No newline at end of file