Skip to content

Commit fd300a7

Browse files
committed
expose page & total count of entries in PostHistory controller
1 parent e5574b9 commit fd300a7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

app/controllers/post_history_controller.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ def post
66
return not_found
77
end
88

9-
@history = PostHistory.where(post_id: params[:id])
10-
.includes(:post_history_type, :user, post_history_tags: [:tag])
11-
.order(created_at: :desc, id: :desc).paginate(per_page: 20, page: params[:page])
9+
base_query = PostHistory.where(post_id: params[:id])
10+
.includes(:post_history_type, :user, post_history_tags: [:tag])
11+
.order(created_at: :desc, id: :desc)
12+
13+
@history = base_query.paginate(per_page: 20, page: params[:page])
14+
15+
@count = base_query.count
16+
17+
@page = params[:page].nil? ? 1 : params[:page]
18+
1219
render layout: 'without_sidebar'
1320
end
1421
end

0 commit comments

Comments
 (0)