pools/show: fix N+1 query on pool show page.

Fix a N+1 query when fetching posts to render thumbnails. Also adds
support for the `limit` url param on the posts show page.
This commit is contained in:
evazion
2019-08-08 23:12:40 -05:00
parent 6d171f44c4
commit 4f024d2360
4 changed files with 14 additions and 18 deletions

View File

@@ -39,7 +39,7 @@ class PoolsController < ApplicationController
def show
@pool = Pool.find(params[:id])
@post_set = PostSets::Pool.new(@pool, params[:page])
@posts = @pool.posts.paginate(params[:page], limit: params[:limit], count: @pool.post_count)
respond_with(@pool)
end