From ac71223b6bea54e556c1c72b68d56a6d1ab367c9 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Fri, 24 Feb 2017 14:27:38 -0600 Subject: [PATCH] init kaminari --- Gemfile | 1 + Gemfile.lock | 13 +++++++++++++ app/controllers/admin/result_controller.rb | 1 + app/views/admin/result/index.html.erb | 1 + config/initializers/kaminari_config.rb | 12 ++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 config/initializers/kaminari_config.rb diff --git a/Gemfile b/Gemfile index fec0016..d8447a6 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'rails', '~> 5.0', '>= 5.0.1' gem 'jbuilder', '~> 2.6' gem 'jquery-rails' gem 'json', '~> 2.0.2' +gem 'kaminari' gem 'mailjet', '~> 1.3.8' gem 'puma', '~> 3.0' gem 'pundit' diff --git a/Gemfile.lock b/Gemfile.lock index b6f62c5..bbe87c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -124,6 +124,18 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.0.3) + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -314,6 +326,7 @@ DEPENDENCIES jbuilder (~> 2.6) jquery-rails json (~> 2.0.2) + kaminari listen mailjet (~> 1.3.8) minitest-reporters diff --git a/app/controllers/admin/result_controller.rb b/app/controllers/admin/result_controller.rb index f217cd0..8675567 100644 --- a/app/controllers/admin/result_controller.rb +++ b/app/controllers/admin/result_controller.rb @@ -14,6 +14,7 @@ module Admin @candidates = Candidate.where(completed: true) .includes(:recruiter) .order("#{sort_column} #{sort_direction}") + .page(params[:page]) end def view diff --git a/app/views/admin/result/index.html.erb b/app/views/admin/result/index.html.erb index 1561f60..82703c9 100644 --- a/app/views/admin/result/index.html.erb +++ b/app/views/admin/result/index.html.erb @@ -24,4 +24,5 @@ <% end %> + <%= paginate @candidates %> diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb new file mode 100644 index 0000000..373150f --- /dev/null +++ b/config/initializers/kaminari_config.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +Kaminari.configure do |config| + config.default_per_page = 10 + # 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.params_on_first_page = false +end