COUNT query to find out total_count sometimes very slow. But if I am caching values of items_amount or such field in model I want to use it for kaminari pagination.
EXAMPLE: I have model
Category (:id, :title, :items_amount)
And then on show view I want to
<%= paginate @items, total_count: @category.items_amount %>
So like paginate_array, but in paginate. It is very useful for perfomance.
Is there a feature like this or how I can add it?
Like will_paginate
gem, where we can do it like this
.paginate(page: params[:page], per_page: 72, total_entries: @category.items_amount)