Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

require a class for cache computations

  • Loading branch information...
commit 64669c11174162560aa490b57f2f8b0e45620fc7 1 parent 9b2cce3
@tenderlove tenderlove authored
View
2  activerecord/lib/active_record/associations/preloader.rb
@@ -85,7 +85,7 @@ class Preloader #:nodoc:
def initialize(records, associations, preload_scope = nil)
@records = Array.wrap(records).compact.uniq
@associations = Array.wrap(associations)
- @preload_scope = preload_scope || Relation.create(nil, nil)
+ @preload_scope = preload_scope || Relation.new(nil, nil)
end
def run
View
4 activerecord/lib/active_record/relation/delegation.rb
@@ -81,7 +81,9 @@ def create(klass, *args)
# Cache the constants in @@subclasses because looking them up via const_get
# make instantiation significantly slower.
def relation_class_for(klass)
- if klass && (klass_name = klass.name)
+ klass_name = klass.name
+
+ if klass_name
my_cache = @@subclasses.compute_if_absent(self) { ThreadSafe::Cache.new }
# This hash is keyed by klass.name to avoid memory leaks in development mode
my_cache.compute_if_absent(klass_name) do
Please sign in to comment.
Something went wrong with that request. Please try again.