8000 [BugFix Issue #106] authorize to override count using pagy · davidcelis/api-pagination@a0c9f3d · GitHub
[go: up one dir, main page]

Skip to content

Commit a0c9f3d

Browse files
committed
[BugFix Issue #106] authorize to override count using pagy
1 parent 33b35b8 commit a0c9f3d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/api-pagination.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ def paginate_with_pagy(collection, options)
6464
end
6565

6666
def pagy_from(collection, options)
67-
count = collection.is_a?(Array) ? collection.count : collection.count(:all)
67+
if options[:count]
68+
count = options[:count]
69+
else
70+
count = collection.is_a?(Array) ? collection.count : collection.count(:all)
71+
end
72+
6873
Pagy.new(count: count, items: options[:per_page], page: options[:page])
6974
end
7075

0 commit comments

Comments
 (0)
0