Fix vehicle name fallback not applied in select by replacing pluck with model instances

This commit is contained in:
2026-04-09 09:42:45 -04:00
parent cc94401a1f
commit 35542ba1b9
@@ -18,14 +18,18 @@ module Vehicles
def view_issues_form_details_bottom(context={}) def view_issues_form_details_bottom(context={})
# Load the customer's vehicles for selection in the issue form. # Load the customer's vehicles for selection in the issue form.
vehicles = context[:issue].customer&.vehicles || []
context[:controller].send(:render_to_string, { context[:controller].send(:render_to_string, {
partial: 'issues/form_hook_vehicles', partial: 'issues/form_hook_vehicles',
locals: { locals: {
vehicle: context[:form].select( :vehicle_id, vehicle: context[:form].select(
context[:issue].customer ? context[:issue].customer.vehicles.pluck(:name, :id) : [], :vehicle_id,
selected: context[:issue].vehicle ? context[:issue].vehicle.id : nil, vehicles.map { |v| [v.name, v.id] },
include_blank: true ) selected: context[:issue].vehicle&.id,
} include_blank: true
)
}
}) })
end end