Skip to content

Commit

Permalink
expose page & total count of entries in PostHistory controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Oaphi committed Oct 30, 2023
1 parent e5574b9 commit 532b4fb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/controllers/post_history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ def post
return not_found
end

@history = PostHistory.where(post_id: params[:id])
.includes(:post_history_type, :user, post_history_tags: [:tag])
.order(created_at: :desc, id: :desc).paginate(per_page: 20, page: params[:page])
base_query = PostHistory.where(post_id: params[:id])
.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])

@count = base_query.count

@page = params[:page].nil? ? 1 : params[:page]

render layout: 'without_sidebar'
end
end

0 comments on commit 532b4fb

Please sign in to comment.