aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/association.rb2
-rw-r--r--activerecord/lib/active_record/scoping/named.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index e42162c740..0f330af2f6 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -134,7 +134,7 @@ module ActiveRecord
end
def extensions
- extensions = klass.all.extensions | reflection.extensions
+ extensions = klass.default_extensions | reflection.extensions
if scope = reflection.scope
extensions |= klass.unscoped.instance_exec(owner, &scope).extensions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index d03c23fe5c..93c6f1d87e 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -34,6 +34,14 @@ module ActiveRecord
build_default_scope(scope) || scope
end
+ def default_extensions # :nodoc:
+ if scope = current_scope || build_default_scope
+ scope.extensions
+ else
+ []
+ end
+ end
+
# Adds a class method for retrieving and querying objects.
# The method is intended to return an ActiveRecord::Relation
# object, which is composable with other scopes.