aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-12-21 17:51:16 -0500
committereileencodes <eileencodes@gmail.com>2015-01-02 17:15:31 -0500
commit96e277c03b7e62e33858ea9e254c9ed88625778f (patch)
tree423eb8217f4953a2e88d0e36a731b52bc476017f /activerecord
parent0408e212ca224bb25159f3e6db2a9c64cdea1200 (diff)
downloadrails-96e277c03b7e62e33858ea9e254c9ed88625778f.tar.gz
rails-96e277c03b7e62e33858ea9e254c9ed88625778f.tar.bz2
rails-96e277c03b7e62e33858ea9e254c9ed88625778f.zip
Add `#all_includes` method to reflections
`yield` instead of relying on checking if the reflection is equal to the `chain_head`.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_scope.rb4
-rw-r--r--activerecord/lib/active_record/reflection.rb2
2 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb
index 1f77a083aa..4fa227342f 100644
--- a/activerecord/lib/active_record/associations/association_scope.rb
+++ b/activerecord/lib/active_record/associations/association_scope.rb
@@ -121,6 +121,8 @@ module ActiveRecord
super(reflection)
@alias_name = alias_name
end
+
+ def all_includes; nil; end
end
def get_chain(refl, association, tracker)
@@ -161,7 +163,7 @@ module ActiveRecord
scope.merge! item.except(:where, :includes, :bind)
end
- if reflection == chain_head
+ reflection.all_includes do
scope.includes! item.includes_values
end
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 111911b575..25fda8f110 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -970,6 +970,8 @@ module ActiveRecord
def alias_name
Arel::Table.new(table_name)
end
+
+ def all_includes; yield; end
end
end
end