From 8129131a3c298e8e14ad4e3351062a288f651e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Tue, 14 Feb 2017 19:09:19 +0100 Subject: [PATCH] adds pagination to officer assignments --- .../admin/poll/officer_assignments_controller.rb | 7 ++++++- app/views/admin/poll/officer_assignments/index.html.erb | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index b14f99a6a..f3102172c 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -5,7 +5,12 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController before_action :load_booth_assignment, only: [:create] def index - @officers = @poll.officer_assignments.includes(officer: :user).select(:officer_id).distinct.map(&:officer) + @officers = ::Poll::Officer. + includes(:user). + order('users.username'). + where( + id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id) + ).page(params[:page]).per(50) end def by_officer diff --git a/app/views/admin/poll/officer_assignments/index.html.erb b/app/views/admin/poll/officer_assignments/index.html.erb index e4c3e3052..f6e75c602 100644 --- a/app/views/admin/poll/officer_assignments/index.html.erb +++ b/app/views/admin/poll/officer_assignments/index.html.erb @@ -37,5 +37,7 @@ <% end %> + + <%= paginate @officers %> <% end %> \ No newline at end of file