aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2012-12-02 21:24:47 +0100
committerYves Senn <yves.senn@garaio.com>2012-12-04 11:52:08 +0100
commitdb51704bd9458635ad82e6a7de56a9fd56db64d4 (patch)
treef7e3cf4d528c38145c0e547fd345d2d19823fa6c /activerecord/test/models
parentc7e4ee79326d81f78cfa3d958a8fce34fde83a15 (diff)
downloadrails-db51704bd9458635ad82e6a7de56a9fd56db64d4.tar.gz
rails-db51704bd9458635ad82e6a7de56a9fd56db64d4.tar.bz2
rails-db51704bd9458635ad82e6a7de56a9fd56db64d4.zip
Do not instantiate intermediate AR objects when eager loading.
Closes #3313
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/developer.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index 622dd75aeb..1c048bb6b4 100644
--- a/activerecord/test/models/developer.rb
+++ b/activerecord/test/models/developer.rb
@@ -57,6 +57,16 @@ class Developer < ActiveRecord::Base
def log=(message)
audit_logs.build :message => message
end
+
+ after_find :track_instance_count
+ cattr_accessor :instance_count
+
+ def track_instance_count
+ self.class.instance_count ||= 0
+ self.class.instance_count += 1
+ end
+ private :track_instance_count
+
end
class AuditLog < ActiveRecord::Base