・ Ruby 2.5.7
・ Rails 126.96.36.199
I want to display only 10 items per page using the pagination function
The image looks like this
First install gem
To implement the pagination function, use the gem “kaminari”.
First, describe kaminari in the gemfile.
After adding to the Gemfile, run bundle install in the terminal to install kaminari.
Then execute the following command
Execute the following to create the kaminari configuration file. If you move the numbers in this file, you can set how many items can be displayed per page.
You can modify the design of kaminari that is generated by executing the following.
For details, this article was easy to understand.
Changed view and controller for pagination
To use kaminari, add the following to the view file you want to use.
The controller also got it with all, but modify it as follows.
If you specify reverse_order, it will be displayed in the newest order.
Enter how many items you want to display in kaminari_config.rb in the config / initializers folder and you’re done! !!