Method: ActiveSupportMethods#underscore

Defined in:
lib/core_ext/string.rb

#underscoreObject



10
11
12
13
14
15
16
# File 'lib/core_ext/string.rb', line 10

def underscore
  gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end