Skip to content

Commit

Permalink
Merge pull request #82 from ysyyork/remove_extra_db_query
Browse files Browse the repository at this point in the history
remove the extra db query
  • Loading branch information
davidcelis authored May 25, 2017
2 parents 8184db7 + 906b096 commit b26c72f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/api-pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def default_per_page_for_will_paginate(collection)
end

def detect_model(collection)
collection.first.class
if collection.respond_to?(:table_name)
collection.table_name.singularize.capitalize.constantize
else
collection.first.class
end
end
end
end
Expand Down

0 comments on commit b26c72f

Please sign in to comment.