aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/inheritance.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-11 23:05:40 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-11 23:05:40 +0900
commit538b19c47eadc43c923527d7c0a4caa66b5cda7e (patch)
tree23e5d9a7eddaeacdd975d11142272eb67ed00c11 /activerecord/lib/active_record/inheritance.rb
parent517a54501d2de1225327296adde8efb91774b237 (diff)
downloadrails-538b19c47eadc43c923527d7c0a4caa66b5cda7e.tar.gz
rails-538b19c47eadc43c923527d7c0a4caa66b5cda7e.tar.bz2
rails-538b19c47eadc43c923527d7c0a4caa66b5cda7e.zip
Refactor object creation from relation to avoid pushing scope attributes
Pushing scope attributes was added at d4007d5 for fixing inheritance object creation. But it was not a better fix, since we could just pull that on demand in `Inheritance` module.
Diffstat (limited to 'activerecord/lib/active_record/inheritance.rb')
-rw-r--r--activerecord/lib/active_record/inheritance.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index 6891c575c7..b25057acda 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -55,6 +55,10 @@ module ActiveRecord
if has_attribute?(inheritance_column)
subclass = subclass_from_attributes(attributes)
+ if subclass.nil? && scope_attributes = current_scope&.scope_for_create
+ subclass = subclass_from_attributes(scope_attributes)
+ end
+
if subclass.nil? && base_class?
subclass = subclass_from_attributes(column_defaults)
end