Skip to content

Commit e06b444

Browse files
committed
Add count_records method to allow easier override for non activerecord counting.
Addresses issue in #714
1 parent 09b5f2c commit e06b444

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/jsonapi/resource.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,13 @@ def sort_records(records, order_options, context = {})
628628
apply_sort(records, order_options, context)
629629
end
630630

631+
# Assumes ActiveRecord's counting. Override if you need a different counting method
632+
def count_records(records)
633+
records.count(:all)
634+
end
635+
631636
def find_count(filters, options = {})
632-
filter_records(filters, options).count(:all)
637+
count_records(filter_records(filters, options))
633638
end
634639

635640
# Override this method if you have more complex requirements than this basic find method provides

0 commit comments

Comments
 (0)