2019-09-03 13:45:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PaginatedCollection
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def redirect_out_of_range(collection, total_pages = collection.total_pages)
|
2020-08-12 02:09:53 -04:00
|
|
|
return false if total_pages == 0
|
2019-09-03 13:45:00 -04:00
|
|
|
|
|
|
|
out_of_range = collection.current_page > total_pages
|
|
|
|
|
|
|
|
if out_of_range
|
|
|
|
redirect_to(url_for(safe_params.merge(page: total_pages, only_path: true)))
|
|
|
|
end
|
|
|
|
|
|
|
|
out_of_range
|
|
|
|
end
|
|
|
|
end
|