Makes it possible to do "posts".singularize that returns "post" and "MegaCoolClass".underscore that returns "mega_cool_class".
Methods
- camelcase
- camelize
- classify
- constantize
- dasherize
- 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(first_letter = :upper) 16: case first_letter 17: when :upper then Inflector.camelize(self, true) 18: when :lower then Inflector.camelize(self, false) 19: end 20: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 44 44: def classify 45: Inflector.classify(self) 46: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 58 58: def constantize 59: Inflector.constantize(self) 60: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 32 32: def dasherize 33: Inflector.dasherize(self) 34: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 36 36: def demodulize 37: Inflector.demodulize(self) 38: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 54 54: def foreign_key(separate_class_name_and_id_with_underscore = true) 55: Inflector.foreign_key(self, separate_class_name_and_id_with_underscore) 56: 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 50 50: def humanize 51: Inflector.humanize(self) 52: 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 40 40: def tableize 41: Inflector.tableize(self) 42: 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 23 23: def titleize 24: Inflector.titleize(self) 25: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb, line 28 28: def underscore 29: Inflector.underscore(self) 30: end