Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the total count after Kaminari pagination

I am using rails 3.2. I am paginating my results using .page(1).per_page(10)

like

@users = User.method().page(1).per_page(10)

Now how to find the total count of the users from the pagination

As because @users.count gives 10 from the first page and not the total count

How to get the total count of the users even after pagination

EDIT : @users.total_count gives the whole paginated count

like image 488
useranon Avatar asked Jun 13 '12 10:06

useranon


1 Answers

As mentioned in the question, you can get the total count of the records with

@users.total_count

I've added this as an answer for the sake of completeness.

like image 139
Jon Cairns Avatar answered Oct 16 '22 02:10

Jon Cairns