Permalink
Browse files

Simplify conditions within apply_join_dependency

  • Loading branch information...
1 parent cd04a99 commit 1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f @Empact Empact committed May 10, 2013
Showing with 5 additions and 9 deletions.
  1. +5 −9 activerecord/lib/active_record/relation/finder_methods.rb
@@ -231,16 +231,12 @@ def apply_join_dependency(relation, join_dependency)
relation = association.join_relation(relation)
end
- limitable_reflections = using_limitable_reflections?(join_dependency.reflections)
-
- if !limitable_reflections && relation.limit_value
- limited_id_condition = construct_limited_ids_condition(relation)
- relation = relation.where(limited_id_condition)
+ if using_limitable_reflections?(join_dependency.reflections)
+ relation
+ else
+ relation = relation.where(construct_limited_ids_condition(relation)) if relation.limit_value
+ relation.except(:limit, :offset)
end
-
- relation = relation.except(:limit, :offset) unless limitable_reflections
-
- relation
end
def construct_limited_ids_condition(relation)

0 comments on commit 1dcb1cc

Please sign in to comment.