Skip to content

Commit

Permalink
expose number of pages in PostHistory controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Oaphi committed Oct 30, 2023
1 parent fc9f889 commit 09447f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/post_history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ def post
.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])
per_page = 20

@history = base_query.paginate(per_page: per_page, page: params[:page])

@count = base_query.count

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

@pages = (@count.to_f / per_page.to_f).ceil

render layout: 'without_sidebar'
end
end

0 comments on commit 09447f3

Please sign in to comment.