From ce8c7eb075c86821d15fe74a5287f31890e4bab9 Mon Sep 17 00:00:00 2001 From: Matus Kmit Date: Thu, 27 Mar 2014 10:32:09 +0100 Subject: [PATCH] [DEPRECATION] change count(distinct: true) to distinct.count --- app/models/contract.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contract.rb b/app/models/contract.rb index 2a75642e33..a81bb8cdd5 100644 --- a/app/models/contract.rb +++ b/app/models/contract.rb @@ -139,7 +139,7 @@ def self.filter(params, user = nil, inventory_pool = nil) contracts = contracts.where(Contract.arel_table[:created_at].lt(params[:range][:end_date])) if params[:range] and params[:range][:end_date] contracts = contracts.order(Contract.arel_table[:created_at].desc) # computing total_entries with count(distinct: true) explicitly, because default contracts.count used by paginate plugin seems to override the DISTINCT option and thus returns wrong result. See https://stackoverflow.com/questions/7939719/will-paginate-generates-wrong-number-of-page-links - contracts = contracts.paginate(:page => params[:page]||1, :per_page => [(params[:per_page].try(&:to_i) || 20), 100].min, :total_entries => contracts.count(distinct: true)) unless params[:paginate] == "false" + contracts = contracts.paginate(:page => params[:page]||1, :per_page => [(params[:per_page].try(&:to_i) || 20), 100].min, :total_entries => contracts.distinct.count) unless params[:paginate] == "false" contracts end