Pagination - IvanAlvarezEnri/dragon-squad-api GitHub Wiki

What gem do you use?

https://github.com/kaminari/kaminari

We used the gem 'Kaminari' for pagination because it was the most used at

https://www.ruby-toolbox.com/categories/pagination

and after taking a look at how it works and his functionality, we thought it was the best gem we could use for this.

How it works?

Kaminari adds a method to all array that allows splitting in group of X number of objects, only add .page(n) at the end with 'n' being the page number you want to get. There are a lot of methods you can use, but we only use this one and total_page to see how many pages the array has. The number of objects per page can be declared at kaminari_config.rb. We set it to 20 but is 25 at default.