method
safe_constantize
v3.2.13 -
Show latest stable
- Class:
String
safe_constantize()public
safe_constantize tries to find a declared constant with the name specified in the string. It returns nil when the name is not in CamelCase or is not initialized. See ActiveSupport::Inflector.safe_constantize
Examples
"Module".safe_constantize # => Module "Class".safe_constantize # => Class "blargle".safe_constantize # => nil
1Note
How safe is this?
Could this be used against a user supplied fragment like in a url route ?