lib/jsonapi/paginator.rb in jsonapi-resources-0.7.1.beta1 vs lib/jsonapi/paginator.rb in jsonapi-resources-0.7.1.beta2

- old
+ new

@@ -56,11 +56,11 @@ if @offset > 0 previous_offset = @offset - @limit previous_offset = 0 if previous_offset < 0 - links_page_params['previous'] = { + links_page_params['prev'] = { 'offset' => previous_offset, 'limit' => @limit } end @@ -129,17 +129,21 @@ def self.requires_record_count true end + def calculate_page_count(record_count) + (record_count / @size.to_f).ceil + end + def apply(relation, _order_options) offset = (@number - 1) * @size relation.offset(offset).limit(@size) end def links_page_params(options = {}) record_count = options[:record_count] - page_count = (record_count / @size.to_f).ceil + page_count = calculate_page_count(record_count) links_page_params = {} links_page_params['first'] = { 'number' => 1,