aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2016-03-08 11:46:11 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2016-07-30 15:28:33 +0900
commit411e4597d552aa091cfe3dc76a83bdaffe02da1a (patch)
treea7c06d6df27915249734789f7f995b55f17e79e6 /activerecord/lib/active_record/reflection.rb
parent815b730b1b79158511f9f4c8465c476b9fe9b7e0 (diff)
downloadrails-411e4597d552aa091cfe3dc76a83bdaffe02da1a.tar.gz
rails-411e4597d552aa091cfe3dc76a83bdaffe02da1a.tar.bz2
rails-411e4597d552aa091cfe3dc76a83bdaffe02da1a.zip
Preserve readonly flag only for readonly association
Fixes #24093
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index bf398b0d40..18428d49e8 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -311,6 +311,10 @@ module ActiveRecord
active_record == other_aggregation.active_record
end
+ def scope_for(klass)
+ scope ? klass.unscoped.instance_exec(nil, &scope) : klass.unscoped
+ end
+
private
def derive_class_name
name.to_s.camelize