diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 3123839a10..32315c4994 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -207,7 +207,9 @@ module ActiveRecord def association_scope_cache(conn) key = conn.prepared_statements - @association_scope_cache[key] ||= @scope_lock.synchronize { yield } + @association_scope_cache[key] ||= @scope_lock.synchronize { + @association_scope_cache[key] ||= yield + } end # Returns a new, unsaved instance of the associated class. +attributes+ will |