具有包含模块和类名的字符串,如下所示:
"Admin::MetaDatasController"
如何获取实际的类?
如果没有模块,下面的代码可以工作:
Kernel.const_get("MetaDatasController")
但它与模块断开了:
ruby-1.8.7-p174 > Kernel.const_get("Admin::MetaDatasController")
NameError: wrong constant name Admin::MetaDatasController
from (irb):34:in `const_get'
from (irb):34
ruby-1.8.7-p174 >
https://stackoverflow.com/questions/3163641
复制相似问题