How to get the total count after Kaminari pagination

useranon picture useranon · Jun 13, 2012 · Viewed 17.8k times · Source

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

Answer

Jon Cairns picture Jon Cairns · Nov 5, 2012

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.