pools/show: fix pagination to respect user's posts-per-page setting.
This commit is contained in:
@@ -30,16 +30,18 @@ class PoolsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gallery
|
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")
|
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)
|
@post_set = PostSets::PoolGallery.new(@pools)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
limit = params[:limit].presence || CurrentUser.user.per_page
|
||||||
|
|
||||||
@pool = Pool.find(params[:id])
|
@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)
|
respond_with(@pool)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<span class="inactive">(deleted)</span>
|
<span class="inactive">(deleted)</span>
|
||||||
<% end %>
|
<% 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" %>
|
<%= link_to "page #{pool.last_page}", pool_path(pool, :page => pool.last_page), :class => "last-page" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user