From b4438b29d6b7131d6800b48f813bf3ba4ed30bd5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 2 Dec 2012 21:21:28 +0000 Subject: [PATCH] Replaces find(:all) calls in classic_pagination. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10924 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../classic_pagination/lib/pagination.rb | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/plugins/classic_pagination/lib/pagination.rb b/lib/plugins/classic_pagination/lib/pagination.rb index 6a3e1a97b..0354d5aa6 100644 --- a/lib/plugins/classic_pagination/lib/pagination.rb +++ b/lib/plugins/classic_pagination/lib/pagination.rb @@ -173,21 +173,28 @@ module ActionController # the +model+ and given +conditions+. Override this method to implement a # custom counter. def count_collection_for_pagination(model, options) - model.count(:conditions => options[:conditions], - :joins => options[:join] || options[:joins], - :include => options[:include], - :select => (options[:group] ? "DISTINCT #{options[:group]}" : options[:count])) + model. + where(options[:conditions]). + joins(options[:join] || options[:joins]). + includes(options[:include]). + select(options[:group] ? "DISTINCT #{options[:group]}" : options[:count]). + count end # Returns a collection of items for the given +model+ and +options[conditions]+, # ordered by +options[order]+, for the current page in the given +paginator+. # Override this method to implement a custom finder. def find_collection_for_pagination(model, options, paginator) - model.find(:all, :conditions => options[:conditions], - :order => options[:order_by] || options[:order], - :joins => options[:join] || options[:joins], :include => options[:include], - :select => options[:select], :limit => options[:per_page], - :group => options[:group], :offset => paginator.current.offset) + model. + where(options[:conditions]). + order(options[:order_by] || options[:order]). + joins(options[:join] || options[:joins]). + includes(options[:include]). + select(options[:select]). + limit(options[:per_page]). + group(options[:group]). + offset(paginator.current.offset). + all end protected :create_paginators_and_retrieve_collections,