mislav/will_paginate — pull request #343 by sayap (2013-10-31 07:48:31+00:00)
Title: AR: Do not spawn additional queries when rendering page_entries_info.

`collection.first.class` will spawn a LIMIT 1 query, while `collection.empty?`
will spawn a COUNT query. The latter is not a problem since a COUNT query is
needed anyway, so redundant ones will retrieve from cache. The former, however,
can add unnecessary load to the database.

As far as I can tell, ActiveRecord::Relation has a `klass` attribute since the
beginning, so it should be fine. The attribute is also aliased as `model` since
https://github.com/rails/rails/pull/6606, though this change is only available
in Rails 4.x.