For group by date I used group_by
method.
Example: Product.all.group_by {|d| d.created_at } # return Hash
But kaminari not support Hash. I use Mongoid and me need group by date with page navigation (kaminari). How do it?
Kaminari only support paginate on array for example
Kaminari.paginate_array(an_array).page(1).per(10)
group_by is not mongoid method, it Array's method, it is grouping all data in memory. In order to use mongoid grouping feature, you need use mongodb map/reduce.
If you do need group result in memory, and show it in view, you need manually convert hash to Array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With