diff --git a/app/controllers/post_history_controller.rb b/app/controllers/post_history_controller.rb index 80a37de1c..dbc22a209 100644 --- a/app/controllers/post_history_controller.rb +++ b/app/controllers/post_history_controller.rb @@ -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