diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 3c75200f820f1b32981fc0af8d8986a4164d07dc..43e4529575f05c5338d052c74c3625ec8d2c91e1 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -155,7 +155,7 @@ def calculate(operation, column_name, options = {}) relation.where(construct_conditions(options[:conditions], scope)) relation.where(construct_arel_limited_ids_condition(options, join_dependency)) if join_dependency && !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - relation.order(construct_order(options[:order], scope)) + relation.order(options[:order]) relation.take(options[:limit]) relation.skip(options[:offset])