From f1926b321deb8b922dead991fb4d8bea42699f9f Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Tue, 3 Sep 2019 19:45:00 +0200 Subject: Add controller concern for paginated collections We had similar code in a few places to redirect to the last page if the given page number is out of range. This unifies the handling in a new controller concern and adds usage of it in all snippet listings. --- app/controllers/explore/snippets_controller.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/controllers/explore') diff --git a/app/controllers/explore/snippets_controller.rb b/app/controllers/explore/snippets_controller.rb index 6192b594593..d4c6aae2ca8 100644 --- a/app/controllers/explore/snippets_controller.rb +++ b/app/controllers/explore/snippets_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class Explore::SnippetsController < Explore::ApplicationController + include PaginatedCollection include Gitlab::NoteableMetadata def index @@ -9,6 +10,8 @@ class Explore::SnippetsController < Explore::ApplicationController .page(params[:page]) .inc_author + return if redirect_out_of_range(@snippets) + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end end -- cgit v1.2.3