diff --git a/lib/pagy/extras/elasticsearch_rails.rb b/lib/pagy/extras/elasticsearch_rails.rb index 68b078ce9..a44098d66 100644 --- a/lib/pagy/extras/elasticsearch_rails.rb +++ b/lib/pagy/extras/elasticsearch_rails.rb @@ -13,11 +13,7 @@ class Pagy def self.new_from_elasticsearch_rails(response, vars={}) vars[:items] = response.search.options[:size] || 10 vars[:page] = (response.search.options[:from] || 0) / vars[:items] + 1 - total = if response.respond_to?(:raw_response) - response.raw_response['hits']['total'] - else - response.response['hits']['total'] - end + total = response.respond_to?(:raw_response) ? response.raw_response['hits']['total'] : response.response['hits']['total'] vars[:count] = total.is_a?(Hash) ? total['value'] : total new(vars) end