mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
a930f5ba06
### 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 ``` |
||
---|---|---|
.. | ||
a | ||
class_folder | ||
html | ||
load_path | ||
module_folder | ||
module_with_custom_const_missing/a | ||
prepend | ||
application.rb | ||
circular1.rb | ||
circular2.rb | ||
class_folder.rb | ||
conflict.rb | ||
counting_loader.rb | ||
cross_site_dependency.rb | ||
d.rb | ||
em.rb | ||
loads_constant.rb | ||
multiple_constant_file.rb | ||
nested_with_require_parent.rb | ||
prepend.rb | ||
raises_arbitrary_exception.rb | ||
raises_load_error.rb | ||
raises_name_error.rb | ||
raises_no_method_error.rb | ||
requires_constant.rb | ||
should_not_be_required.rb | ||
throws.rb | ||
typo.rb |