From 4abbdbdf1656e9bed6f744723a901cbaf6878df4 Mon Sep 17 00:00:00 2001 From: Sammy Larbi Date: Sun, 31 Aug 2014 14:18:02 -0500 Subject: Skip StatementCache for eager loaded associations (Fixes #16761) Eagerly loaded collection and singular associations are ignored by the StatementCache, which causes errors when the queries they generate reference columns that were not eagerly loaded. This commit skips the creation of the StatementCache as a fix for these scenarios. --- activerecord/test/models/post.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/models/post.rb') diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 56a31011da..256b720c9a 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -218,3 +218,9 @@ class PostThatLoadsCommentsInAnAfterSaveHook < ActiveRecord::Base post.comments.load end end + +class PostWithCommentWithDefaultScopeReferencesAssociation < ActiveRecord::Base + self.table_name = 'posts' + has_many :comment_with_default_scope_references_associations, foreign_key: :post_id + has_one :first_comment, class_name: "CommentWithDefaultScopeReferencesAssociation", foreign_key: :post_id +end -- cgit v1.2.3