diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-03 03:41:55 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-03 03:41:55 +0900 |
commit | b44e5dc87b11ca801a72fa31b3feaa5af6672e23 (patch) | |
tree | 56a6af0a09d6c3dfc6072d53b9cf7c1e50720fbb /activerecord/lib | |
parent | 0255cf94b0871230aba106543c17918caafbef0e (diff) | |
download | rails-b44e5dc87b11ca801a72fa31b3feaa5af6672e23.tar.gz rails-b44e5dc87b11ca801a72fa31b3feaa5af6672e23.tar.bz2 rails-b44e5dc87b11ca801a72fa31b3feaa5af6672e23.zip |
Don't extract `readonly_value` each time
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index be56d27021..d316db2145 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -232,11 +232,6 @@ module ActiveRecord else model = construct_model(ar_parent, node, row, model_cache, id) - if node.reflection.scope && - node.reflection.scope_for(node.base_klass.unscoped).readonly_value - model.readonly! - end - seen[ar_parent.object_id][node][id] = model construct(model, node, row, seen, model_cache) end @@ -257,6 +252,7 @@ module ActiveRecord other.target = model end + model.readonly! if node.readonly? model end end diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 6e5e950e90..4583d89cba 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -54,6 +54,12 @@ module ActiveRecord @tables = tables @table = tables.first end + + def readonly? + return @readonly if defined?(@readonly) + + @readonly = reflection.scope && reflection.scope_for(base_klass.unscoped).readonly_value + end end end end |