v4.0.2 - Show latest stable - 1 note - 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

'Module'.safe_constantize  # => Module
'Class'.safe_constantize   # => Class
'blargle'.safe_constantize # => nil
Show source
Register or log in to add new notes.
January 2, 2015
0 thanks

How safe is this?

Could this be used against a user supplied fragment like in a url route ?