Makes it possible to do "posts".singularize that returns "post" and "MegaCoolClass".underscore that returns "mega_cool_class".
Methods
- camelcase
- camelize
- classify
- constantize
- demodulize
- foreign_key
- humanize
- pluralize
- singularize
- tableize
- titlecase
- titleize
- underscore
Public Instance methods
Alias for camelize
This method is also aliased as
camelcase
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 15
15: def camelize
16: Inflector.camelize(self)
17: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 37
37: def classify
38: Inflector.classify(self)
39: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 51
51: def constantize
52: Inflector.constantize(self)
53: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 29
29: def demodulize
30: Inflector.demodulize(self)
31: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 47
47: def foreign_key(separate_class_name_and_id_with_underscore = true)
48: Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
49: end
Capitalizes the first word and turns underscores into spaces and strips _id, so "employee_salary" becomes "Employee salary" and "author_id" becomes "Author".
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 43
43: def humanize
44: Inflector.humanize(self)
45: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 7 7: def pluralize 8: Inflector.pluralize(self) 9: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 11
11: def singularize
12: Inflector.singularize(self)
13: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 33
33: def tableize
34: Inflector.tableize(self)
35: end
Alias for titleize
This method is also aliased as
titlecase
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 20
20: def titleize
21: Inflector.titleize(self)
22: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 25
25: def underscore
26: Inflector.underscore(self)
27: end