From 1f7b4447a9030ccec542ecaa1e5e11e0d4622a84 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 5 Apr 2010 21:54:39 +0100 Subject: Memoize association.named_scope calls --- activerecord/lib/active_record/associations/association_collection.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/lib/active_record/associations/association_collection.rb') diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 6eda70d0ce..5ecdf1ac8d 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -405,6 +405,9 @@ module ActiveRecord else super end + elsif @reflection.klass.scopes[method] + @_scopes ||= {} + @_scopes[method] ||= with_scope(construct_scope) { @reflection.klass.send(method, *args) } else with_scope(construct_scope) do if block_given? -- cgit v1.2.3