Skip to content

Commit b26c72f

Browse files
authored
Merge pull request #82 from ysyyork/remove_extra_db_query
remove the extra db query
2 parents 8184db7 + 906b096 commit b26c72f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/api-pagination.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ def default_per_page_for_will_paginate(collection)
8181
end
8282

8383
def detect_model(collection)
84-
collection.first.class
84+
if collection.respond_to?(:table_name)
85+
collection.table_name.singularize.capitalize.constantize
86+
else
87+
collection.first.class
88+
end
8589
end
8690
end
8791
end

0 commit comments

Comments
 (0)