instance method
underscore
Ruby on Rails 2.3.18
Since v2.2.3Signature
underscore(camel_cased_word)
The reverse of camelize. Makes an underscored, lowercase form from the expression in the string.
Changes ‘::’ to ‘/’ to convert namespaces to paths.
Examples:
"ActiveRecord".underscore # => "active_record" "ActiveRecord::Errors".underscore # => active_record/errors
Parameters
-
camel_cased_wordreq
Source
# File activesupport/lib/active_support/inflector.rb, line 207
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
Defined in activesupport/lib/active_support/inflector.rb line 207
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Inflector