From dea80a82d837a1883fcea6703b1aa818415cf203 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 4 Oct 2024 16:37:41 +0300 Subject: [PATCH] fix pagination --- app/controllers/template_folders_controller.rb | 2 +- app/controllers/templates_archived_controller.rb | 2 +- app/controllers/templates_dashboard_controller.rb | 4 ++-- config/initializers/pagy.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/template_folders_controller.rb b/app/controllers/template_folders_controller.rb index bd1981f2..87ce435c 100644 --- a/app/controllers/template_folders_controller.rb +++ b/app/controllers/template_folders_controller.rb @@ -7,7 +7,7 @@ class TemplateFoldersController < ApplicationController @templates = @template_folder.templates.active.preload(:author).order(id: :desc) @templates = Templates.search(@templates, params[:q]) - @pagy, @templates = pagy(@templates, items: 12) + @pagy, @templates = pagy(@templates, limit: 12) end def edit; end diff --git a/app/controllers/templates_archived_controller.rb b/app/controllers/templates_archived_controller.rb index 1d2efe34..1f0f1752 100644 --- a/app/controllers/templates_archived_controller.rb +++ b/app/controllers/templates_archived_controller.rb @@ -7,6 +7,6 @@ class TemplatesArchivedController < ApplicationController @templates = @templates.where.not(archived_at: nil).preload(:author, :folder).order(id: :desc) @templates = Templates.search(@templates, params[:q]) - @pagy, @templates = pagy(@templates, items: 12) + @pagy, @templates = pagy(@templates, limit: 12) end end diff --git a/app/controllers/templates_dashboard_controller.rb b/app/controllers/templates_dashboard_controller.rb index 12a6db8a..be9dea75 100644 --- a/app/controllers/templates_dashboard_controller.rb +++ b/app/controllers/templates_dashboard_controller.rb @@ -23,14 +23,14 @@ class TemplatesDashboardController < ApplicationController @template_folders = @template_folders.reject { |e| e.name == TemplateFolder::DEFAULT_NAME } @templates = filter_templates(@templates) - items = + limit = if @template_folders.size < 4 TEMPLATES_PER_PAGE else (@template_folders.size < 7 ? 9 : 6) end - @pagy, @templates = pagy(@templates, items:) + @pagy, @templates = pagy(@templates, limit:) end end diff --git a/config/initializers/pagy.rb b/config/initializers/pagy.rb index 463fa58a..dc79235a 100644 --- a/config/initializers/pagy.rb +++ b/config/initializers/pagy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -Pagy::DEFAULT[:items] = 10 +Pagy::DEFAULT[:limit] = 10 Pagy::DEFAULT.freeze ActiveSupport.on_load(:action_view) do