From 4535191c61b496b1a5e9dc57624581753fa71497 Mon Sep 17 00:00:00 2001 From: Ryan Oblak Date: Tue, 27 Sep 2011 22:39:31 -0700 Subject: Modified String#pluralize to take an optional count parameter. --- railties/guides/source/active_support_core_extensions.textile | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 5aee001545..153a897b1c 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1426,6 +1426,14 @@ The method +pluralize+ returns the plural of its receiver: As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Built-in rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments. ++pluralize+ can also take an optional +count+ parameter. If count == 1 the singular form will be returned. For any other value of +count+ the plural form will be returned: + + +"dude".pluralize(0) # => "dudes" +"dude".pluralize(1) # => "dude" +"dude".pluralize(2) # => "dudes" + + Active Record uses this method to compute the default table name that corresponds to a model: -- cgit v1.2.3