-
-
Save apeckham/1d3c9e3602fc6e8e5885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/sononum/6183139 | |
module Kaminari | |
module ActiveRecordRelationMethods | |
def total_count_with_speed | |
if where_values_hash.empty? | |
sql = "SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname = #{self.connection.quote table_name}" | |
@_hacked_total_count || (@_hacked_total_count = self.connection.execute(sql).first["reltuples"].to_i) | |
else | |
total_count_without_speed | |
end | |
end | |
alias_method_chain :total_count, :speed | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment