Skip to content

Commit

Permalink
Merge pull request #56 from TDT-GmbH/fix-users-roles-pagination
Browse files Browse the repository at this point in the history
Fix users and roles index query for pagination
  • Loading branch information
zaidka authored Jan 10, 2017
2 parents 3f2c790 + e2cc566 commit 1256b79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/controllers/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ class RolesController < ApplicationController

def index
can?(:read, 'roles') do
@roles = Role.all
off = params.include?(:page) ? (Integer(params[:page]) - 1) * Rails.configuration.page_size : 0
lim = Rails.configuration.page_size
@roles = Role.limit(lim).offset(off)
@total = Role.count
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ class UsersController < ApplicationController

def index
can?(:read, 'users') do
@users = User.all
off = params.include?(:page) ? (Integer(params[:page]) - 1) * Rails.configuration.page_size : 0
lim = Rails.configuration.page_size
@users = User.limit(lim).offset(off)
@total = User.count
end
end
Expand Down

0 comments on commit 1256b79

Please sign in to comment.