From 77ffadf166b9bc02b8e66949b5157ebf8375ec35 Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 6 Oct 2020 18:45:11 +0200 Subject: User Kaminari gem for pagination Since we're dealing with lots of resources, we need a way to handle pagination. This gem seems to be the new kid on the block and doing things right, including pagination by default an I18n support. Let's see. Kaminari: https://github.com/kaminari/kaminari --- Gemfile | 2 ++ Gemfile.lock | 13 +++++++++++++ config/initializers/kaminari_config.rb | 14 ++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 config/initializers/kaminari_config.rb diff --git a/Gemfile b/Gemfile index 2d5228b..8a44eed 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,8 @@ gem 'jbuilder', '~> 2.7' gem 'bitfields' # Use Discourse API gem 'discourse_api' +# User pagination +gem 'kaminari' # Enforce stable UUIDs for models gem 'uuid_parameter', '~> 0.2.5' diff --git a/Gemfile.lock b/Gemfile.lock index 7a464f2..6b28c92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,18 @@ GEM jbuilder (2.10.1) activesupport (>= 5.0.0) json (2.3.1) + kaminari (1.2.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) + actionview + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) + activerecord + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -203,6 +215,7 @@ DEPENDENCIES byebug discourse_api jbuilder (~> 2.7) + kaminari listen (~> 3.2) pg (>= 0.18, < 2.0) pry diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb new file mode 100644 index 0000000..4ba6ee3 --- /dev/null +++ b/config/initializers/kaminari_config.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +Kaminari.configure do |config| + # config.default_per_page = 25 + # config.max_per_page = nil + # config.window = 4 + # config.outer_window = 0 + # config.left = 0 + # config.right = 0 + # config.page_method_name = :page + # config.param_name = :page + # config.max_pages = nil + # config.params_on_first_page = false +end -- cgit v1.2.3