lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.25 vs lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.26
- old
+ new
@@ -6,10 +6,11 @@
page_with_options RestPack::Serializer::Options.new(self, params, scope, context)
end
def page_with_options(options)
page = options.scope_with_filters.page(options.page).per(options.page_size)
+ page = page.reorder(options.sorting) if options.sorting.any?
result = RestPack::Serializer::Result.new
result.resources[self.key] = serialize_page(page, options)
result.meta[self.key] = serialize_meta(page, options)
@@ -56,9 +57,10 @@
params = []
params << "page=#{page}" unless page == 1
params << "page_size=#{options.page_size}" unless options.default_page_size?
params << "include=#{options.include.join(',')}" if options.include.any?
+ params << options.sorting_as_url_params if options.sorting.any?
params << options.filters_as_url_params if options.filters.any?
url += '?' + params.join('&') if params.any?
url
end