Skip to content

Commit

Permalink
preserve order on the RHS query
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 21, 2013
1 parent bc77cca commit 8988f0b
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -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
Expand Down

0 comments on commit 8988f0b

Please sign in to comment.