aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMichael Lovitt <michael@lovitt.net>2017-05-18 15:43:49 -0500
committerMichael Lovitt <michael@lovitt.net>2017-05-24 17:26:20 -0500
commitbfc62febac905412cdbcb7698d5a3b3ea5167af3 (patch)
treeb70185e79cf80a1a22d838f8b01c294e99d5c7f4 /activerecord/lib/active_record
parenta24912cb1d34912a16aa27d952beff825e558f1f (diff)
downloadrails-bfc62febac905412cdbcb7698d5a3b3ea5167af3.tar.gz
rails-bfc62febac905412cdbcb7698d5a3b3ea5167af3.tar.bz2
rails-bfc62febac905412cdbcb7698d5a3b3ea5167af3.zip
Performance optimization for ActiveRecord#subclass_from_attributes
This change addresses slowness in ActiveRecord initialization introduced starting in Rails 5.0.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/inheritance.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index fbdaeaae51..236a65eba7 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -217,7 +217,7 @@ module ActiveRecord
def subclass_from_attributes(attrs)
attrs = attrs.to_h if attrs.respond_to?(:permitted?)
if attrs.is_a?(Hash)
- subclass_name = attrs.with_indifferent_access[inheritance_column]
+ subclass_name = attrs[inheritance_column] || attrs[inheritance_column.to_sym]
if subclass_name.present?
find_sti_class(subclass_name)