From bfc62febac905412cdbcb7698d5a3b3ea5167af3 Mon Sep 17 00:00:00 2001 From: Michael Lovitt Date: Thu, 18 May 2017 15:43:49 -0500 Subject: Performance optimization for ActiveRecord#subclass_from_attributes This change addresses slowness in ActiveRecord initialization introduced starting in Rails 5.0. --- activerecord/lib/active_record/inheritance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') 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) -- cgit v1.2.3