adds pagination to officer assignments

This commit is contained in:
Juanjo Bazán
2017-02-14 19:09:19 +01:00
parent 2905c03037
commit 8129131a3c
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -37,5 +37,7 @@
<% end %>
</tbody>
</table>
<%= paginate @officers %>
<% end %>
</div>