aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-03-01 05:43:56 +0100
committerXavier Noria <fxn@hashref.com>2010-03-01 05:43:56 +0100
commit1064c533ceb46562da39b3b0e50709ceaf0d65d4 (patch)
treede507d496d939342c05b8644eddb00ff823b625c /railties/guides/source/active_support_core_extensions.textile
parent51e84bfbd6e53cef8b563bdf99ea47631bece677 (diff)
downloadrails-1064c533ceb46562da39b3b0e50709ceaf0d65d4.tar.gz
rails-1064c533ceb46562da39b3b0e50709ceaf0d65d4.tar.bz2
rails-1064c533ceb46562da39b3b0e50709ceaf0d65d4.zip
AS guide: documents String#singularize
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile23
1 files changed, 23 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 7ee414f34b..c1a79189bd 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -1276,6 +1276,29 @@ end
NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
+h5. +singularize+
+
+The inverse of +pluralize+:
+
+<ruby>
+"tables".singularize # => "table"
+"rubies".singularize # => "ruby"
+"equipment".singularize # => "equipment"
+</ruby>
+
+Associations compute the name of the corresponding default associated class using this method:
+
+<ruby>
+# active_record/reflection.rb
+def derive_class_name
+ class_name = name.to_s.camelize
+ class_name = class_name.singularize if collection?
+ class_name
+end
+</ruby>
+
+NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
+
h3. Extensions to +Numeric+
h4. Bytes