diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index 7a11cb4..fcdbc6c 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -60,10 +60,15 @@ class VehiclesController < ApplicationController # display a specific vehicle def show begin - @vehicle = Vehicle.find_by_id(params[:id]) + @vehicle = Vehicle.includes(issues: [:estimate, :invoices]).find(params[:id]) @vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin - @issues = @vehicle.issues.order(id: :desc) - @closed_issues = (@issues - @issues.open) + @issues = @vehicle.issues + .joins(:status) + .includes(:estimate, :invoices, :status, :project, :tracker, :priority) + .order(id: :desc) + @open_issues = @issues.select { |i| !i.status.is_closed } + @closed_issues = @issues.select { |i| i.status.is_closed } + flash[:error] = t :alert_no_customer if @vehicle.customer.nil? rescue flash[:error] = t :alert_vehicle_not_found diff --git a/app/views/vehicles/show.html.erb b/app/views/vehicles/show.html.erb index 5702f5d..9e4963b 100644 --- a/app/views/vehicles/show.html.erb +++ b/app/views/vehicles/show.html.erb @@ -14,9 +14,9 @@ -