From 9cf5c6262cb57007f5fe4bbc752441a127fe0193 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 22 Sep 2014 05:13:31 +0200 Subject: [PATCH] add pagination to users --- app/controllers/users_controller.rb | 2 +- app/views/users/index.html.erb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4ab9565..f2e73cd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -21,7 +21,7 @@ class UsersController < ApplicationController else @users = User.where.not(id: User.first.id) #Remove first user end - @users = @users.order("role_id desc", "confirmed desc", :name).to_a + @users = @users.order("role_id desc", "confirmed desc", :name).page(params[:page]) end def show diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index e445b8d..74d1bdd 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -4,7 +4,7 @@ <% else %>

<%= title "All Users" %>

<% end %> -

User count: <%= @users.length %>

+

User count: <%= User.count - 1 %>

<% @users.each do |u| %> @@ -16,4 +16,5 @@
<% end %> + <%= paginate @users %> \ No newline at end of file