Permalink
Browse files

preserve order on the RHS query

  • Loading branch information...
1 parent bc77cca commit 8988f0b8beec83a8ead61da93818270e82e76694 @tenderlove tenderlove committed Sep 21, 2013
Showing with 8 additions and 0 deletions.
  1. +8 −0 activerecord/lib/active_record/associations/preloader/association.rb
@@ -133,6 +133,14 @@ def build_scope
scope.select! preload_values[:select] || values[:select] || table[Arel.star]
scope.includes! preload_values[:includes] || values[:includes]
+ if preload_values.key? :order
+ scope.order! preload_values[:order]
+ else
+ if values.key? :order
+ scope.order! values[:order]
+ end
+ end
+
if options[:as]
scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name })
end

0 comments on commit 8988f0b

Please sign in to comment.