From 09447f3e0c97bb1285b22c0d5a852b9084aeb1f6 Mon Sep 17 00:00:00 2001 From: Oleg Valter Date: Mon, 30 Oct 2023 12:44:43 +0300 Subject: [PATCH] expose number of pages in PostHistory controller --- app/controllers/post_history_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/post_history_controller.rb b/app/controllers/post_history_controller.rb index 38641bf5c..47a8c3841 100644 --- a/app/controllers/post_history_controller.rb +++ b/app/controllers/post_history_controller.rb @@ -10,12 +10,16 @@ def post .includes(:post_history_type, :user, post_history_tags: [:tag]) .order(created_at: :desc, id: :desc) - @history = base_query.paginate(per_page: 20, page: params[:page]) + per_page = 20 + + @history = base_query.paginate(per_page: per_page, page: params[:page]) @count = base_query.count @page = params[:page].nil? ? 1 : params[:page].to_i + @pages = (@count.to_f / per_page.to_f).ceil + render layout: 'without_sidebar' end end