提交 f07a9578 编写于 作者: A Aaron Patterson

Merge pull request #5208 from ysoslow/ef79b840

Inject in constantize
......@@ -209,12 +209,10 @@ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
def constantize(camel_cased_word) #:nodoc:
names = camel_cased_word.split('::')
names.shift if names.empty? || names.first.empty?
constant = Object
names.each do |name|
constant = constant.const_get(name, false)
names.inject(Object) do |constant, name|
constant.const_get(name, false)
end
constant
end
# Tries to find a constant with the name specified in the argument string:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册