From 7cc31b97c988ec621ea7e2a00ee4662b1dcc35b5 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 21 Aug 2019 14:31:58 -0500 Subject: [PATCH] pools/show: fix pagination to respect user's posts-per-page setting. --- app/controllers/pools_controller.rb | 8 +++++--- app/views/pools/index.html.erb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index 0b78f81b3..54454f3f4 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -30,16 +30,18 @@ class PoolsController < ApplicationController end def gallery - params[:limit] ||= CurrentUser.user.per_page + limit = params[:limit].presence || CurrentUser.user.per_page search = search_params.presence || ActionController::Parameters.new(category: "series") - @pools = Pool.search(search).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @pools = Pool.search(search).paginate(params[:page], limit: limit, search_count: params[:search]) @post_set = PostSets::PoolGallery.new(@pools) end def show + limit = params[:limit].presence || CurrentUser.user.per_page + @pool = Pool.find(params[:id]) - @posts = @pool.posts.paginate(params[:page], limit: params[:limit], count: @pool.post_count) + @posts = @pool.posts.paginate(params[:page], limit: limit, count: @pool.post_count) respond_with(@pool) end diff --git a/app/views/pools/index.html.erb b/app/views/pools/index.html.erb index 8b67cf090..d5c69fa13 100644 --- a/app/views/pools/index.html.erb +++ b/app/views/pools/index.html.erb @@ -21,7 +21,7 @@ (deleted) <% end %> - <% if pool.post_count > CurrentUser.user.per_page %> + <% if pool.last_page > 1 %> <%= link_to "page #{pool.last_page}", pool_path(pool, :page => pool.last_page), :class => "last-page" %> <% end %>