Flowdock
method

safe_constantize

Importance_2
Ruby on Rails latest stable (v6.1.7.7) - 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.

'Module'.safe_constantize  # => Module
'Class'.safe_constantize   # => Class
'blargle'.safe_constantize # => nil

See ActiveSupport::Inflector.safe_constantize.

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 ?