8000 Use count(:all) with Pagy · davidcelis/api-pagination@08d764c · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 08d764c

Browse files
committed
Use count(:all) with Pagy
1 parent 6c7ff56 commit 08d764c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/api-pagination.rb

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

6666
def pagy_from(collection, options)
67-
Pagy.new(count: collection.count, items: options[:per_page], page: options[:page])
67+
count = collection.is_a?(Array) ? collection.count : collection.count(:all)
68+
Pagy.new(count: count, items: options[:per_page], page: options[:page])
6869
end
6970

7071
def pagy_pages_from(pagy)

0 commit comments

Comments
 (0)
0