From a930f5ba0654e8c8c7ac7b3febbb573d03559a40 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Mon, 7 Jan 2019 14:13:45 -0500 Subject: Fix safe_constantize to not raise a LoadError. ### Summary There was an issues when using `safe_constantize` on a string that has the wrong case. File `em.rb` defines `EM`. `"Em".safe_constantize` causes a little confusion with the autoloader. The autoloader finds file "em.rb", expecting it to define `Em`, but `Em` is not defined. The autoloader raises a `LoadError`, which is good, But `safe_constantize` is defined to return `nil` when a class is not found. ### Before ``` "Em".safe_constantize LoadError: Unable to autoload constant Em, \ expected rails/activesupport/test/autoloading_fixtures/em.rb to define it ``` ### After ``` "Em".safe_constantize # => nil ``` --- activesupport/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activesupport/CHANGELOG.md') diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 360cef2b41..d4eaee9f6d 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references. + + *Keenan Brock* + * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`. `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses. -- cgit v1.2.3