Vehicles paged by Redmine instead of will_paginate

The vehicle search, a customer's vehicles and the customer page's vehicle list use Redmine's paginator
(will_paginate came from redmine_qbo's Gemfile, which no longer has it). The customer page's list keeps
its own page parameter, without per-page links, and lists vehicles by year, make and model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-01 17:47:25 -05:00
1 parent 53991ed087
commit d842b9b724
4 files changed
+22 -9

No files matched your search

+10 -3
View File
@@ -27,13 +27,13 @@ class VehiclesController < ApplicationController
@customer = Customer.find_by(id: params[:customer_id])
return render_404 unless @customer
@vehicles = @customer.vehicles.order(:year, :make, :model).paginate(page: params[:page])
paginate_vehicles(@customer.vehicles.order(:year, :make, :model, :id))
return
end
if params[:search].present?
@vehicles = Vehicle.search_all(params[:search]).paginate(page: params[:page])
redirect_to @vehicles.first if @vehicles.total_entries == 1
paginate_vehicles(Vehicle.search_all(params[:search]).order(:id))
redirect_to @vehicles.first if @vehicle_count == 1
end
end
@@ -115,4 +115,11 @@ class VehiclesController < ApplicationController
render_404
end
# Redmine's paging: @vehicle_count, @vehicle_pages and this page's @vehicles
def paginate_vehicles(scope)
@vehicle_count = scope.count
@vehicle_pages = Paginator.new @vehicle_count, per_page_option, params['page']
@vehicles = scope.limit(@vehicle_pages.per_page).offset(@vehicle_pages.offset).to_a
end
end