2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PaginatedCollection
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def redirect_out_of_range(collection, total_pages = collection.total_pages)
|
2020-10-24 23:57:45 +05:30
|
|
|
return false if total_pages == 0
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
out_of_range = collection.current_page > total_pages
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
redirect_to(url_for(safe_params.merge(page: total_pages, only_path: true))) if out_of_range
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
out_of_range
|
|
|
|
end
|
|
|
|
end
|