diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-02 21:21:28 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-02 21:21:28 +0000 |
commit | b4438b29d6b7131d6800b48f813bf3ba4ed30bd5 (patch) | |
tree | 0c109b4bd27c1bb6ec107d7608a988464970ee8d /lib | |
parent | 7a40e309e423cff76990e40ddb9ee33e892625b0 (diff) | |
download | redmine-b4438b29d6b7131d6800b48f813bf3ba4ed30bd5.tar.gz redmine-b4438b29d6b7131d6800b48f813bf3ba4ed30bd5.zip |
Replaces find(:all) calls in classic_pagination.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10924 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/classic_pagination/lib/pagination.rb | 25 |
1 files 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, |