Replaces find(:all) calls in classic_pagination.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10924 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7a40e309e4
commit
b4438b29d6
|
@ -173,21 +173,28 @@ module ActionController
|
||||||
# the +model+ and given +conditions+. Override this method to implement a
|
# the +model+ and given +conditions+. Override this method to implement a
|
||||||
# custom counter.
|
# custom counter.
|
||||||
def count_collection_for_pagination(model, options)
|
def count_collection_for_pagination(model, options)
|
||||||
model.count(:conditions => options[:conditions],
|
model.
|
||||||
:joins => options[:join] || options[:joins],
|
where(options[:conditions]).
|
||||||
:include => options[:include],
|
joins(options[:join] || options[:joins]).
|
||||||
:select => (options[:group] ? "DISTINCT #{options[:group]}" : options[:count]))
|
includes(options[:include]).
|
||||||
|
select(options[:group] ? "DISTINCT #{options[:group]}" : options[:count]).
|
||||||
|
count
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a collection of items for the given +model+ and +options[conditions]+,
|
# Returns a collection of items for the given +model+ and +options[conditions]+,
|
||||||
# ordered by +options[order]+, for the current page in the given +paginator+.
|
# ordered by +options[order]+, for the current page in the given +paginator+.
|
||||||
# Override this method to implement a custom finder.
|
# Override this method to implement a custom finder.
|
||||||
def find_collection_for_pagination(model, options, paginator)
|
def find_collection_for_pagination(model, options, paginator)
|
||||||
model.find(:all, :conditions => options[:conditions],
|
model.
|
||||||
:order => options[:order_by] || options[:order],
|
where(options[:conditions]).
|
||||||
:joins => options[:join] || options[:joins], :include => options[:include],
|
order(options[:order_by] || options[:order]).
|
||||||
:select => options[:select], :limit => options[:per_page],
|
joins(options[:join] || options[:joins]).
|
||||||
:group => options[:group], :offset => paginator.current.offset)
|
includes(options[:include]).
|
||||||
|
select(options[:select]).
|
||||||
|
limit(options[:per_page]).
|
||||||
|
group(options[:group]).
|
||||||
|
offset(paginator.current.offset).
|
||||||
|
all
|
||||||
end
|
end
|
||||||
|
|
||||||
protected :create_paginators_and_retrieve_collections,
|
protected :create_paginators_and_retrieve_collections,
|
||||||
|
|
Loading…
Reference in New Issue