From 5706d290b0a2501a713fadfb76d9e45c24d26e6a Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sun, 22 Jun 2014 14:48:28 +0200 Subject: `preload` preserves readonly flag on associations. #15853 This is a partial fix for #15853. It only works when a `preload` is issued and not an `eager_load`. I've added a skipped failing test-case to keep in mind that we need to deal with `eager_load`. --- activerecord/lib/active_record/associations/preloader/association.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 441768f302..c0639742be 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -151,6 +151,10 @@ module ActiveRecord end end + if preload_values[:readonly] || values[:readonly] + scope.readonly! + end + if options[:as] scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name }) end -- cgit v1.2.3