aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorNikolay Shebanov <nikolay.shebanov@gmail.com>2013-06-13 17:33:26 +0400
committerNikolay Shebanov <nikolay.shebanov@gmail.com>2013-06-14 11:20:15 +0400
commit7fd36f307a86b64d05f9171ff050c4af3b45725c (patch)
treea4eccf86115874f950eee687ec7a0cbb531196ea /activesupport/lib
parentb3bc3aa5cbe7540de21ae4eb566886e3b8efe6e3 (diff)
downloadrails-7fd36f307a86b64d05f9171ff050c4af3b45725c.tar.gz
rails-7fd36f307a86b64d05f9171ff050c4af3b45725c.tar.bz2
rails-7fd36f307a86b64d05f9171ff050c4af3b45725c.zip
Fix #10932. Treat "" and "::" as invalid on constantize
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 39648727fd..665545db3b 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -219,7 +219,12 @@ module ActiveSupport
# unknown.
def constantize(camel_cased_word)
names = camel_cased_word.split('::')
- names.shift if names.empty? || names.first.empty?
+
+ # Trigger a builtin NameError exception including the ill-formed constant in the message.
+ Object.const_get(camel_cased_word) if names.empty?
+
+ # Remove the first blank element in case of '::ClassName' notation.
+ names.shift if names.size > 1 && names.first.empty?
names.inject(Object) do |constant, name|
if constant == Object