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/lib/active_record/core.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/active_record/core.rb') diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 82b9c79533..2e9c9e3197 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -152,6 +152,7 @@ module ActiveRecord def find_by(*args) return super if current_scope || !(Hash === args.first) || reflect_on_all_aggregations.any? + return super if default_scopes.any? hash = args.first -- cgit v1.2.3 From d5580b91b64daeb114875f24f6d54bbf88428018 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 9 Sep 2014 09:44:48 +0200 Subject: Allow included modules to override association methods. Closes #16684. This is achieved by always generating `GeneratedAssociationMethods` when `ActiveRecord::Base` is subclassed. When some of the included modules of `ActiveRecord::Base` were reordered this behavior was broken as `Core#initialize_generated_modules` was no longer called. Meaning that the module was generated on first access. --- activerecord/lib/active_record/core.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'activerecord/lib/active_record/core.rb') diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 2e9c9e3197..83859e474a 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -183,8 +183,6 @@ module ActiveRecord end def initialize_generated_modules - super - generated_association_methods end -- cgit v1.2.3