aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2013-05-10 11:42:24 +0200
committerBen Woosley <ben.woosley@gmail.com>2013-05-10 17:46:04 +0200
commit1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f (patch)
tree46c2708a1ef07d1e70777c3b6fc31e782c4fc0e4
parentcd04a99ba4b5227fb103b6d4e7504c770833e612 (diff)
downloadrails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.tar.gz
rails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.tar.bz2
rails-1dcb1ccc9d3d4f41e8f1a76ff3465f708189dd2f.zip
Simplify conditions within apply_join_dependency
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 531343782e..9a774b5abc 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -231,16 +231,12 @@ module ActiveRecord
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)