diff options
author | Ryan Oblak <rroblak@gmail.com> | 2011-09-27 22:39:31 -0700 |
---|---|---|
committer | Ryan Oblak <rroblak@gmail.com> | 2011-09-28 12:24:06 -0700 |
commit | 4535191c61b496b1a5e9dc57624581753fa71497 (patch) | |
tree | ee10fb199b2a43f4eadb6cf913d499e133bf59e6 /railties/guides | |
parent | c612183ad19f2c11eb58e4393a759a1016ce4c05 (diff) | |
download | rails-4535191c61b496b1a5e9dc57624581753fa71497.tar.gz rails-4535191c61b496b1a5e9dc57624581753fa71497.tar.bz2 rails-4535191c61b496b1a5e9dc57624581753fa71497.zip |
Modified String#pluralize to take an optional count parameter.
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 8 |
1 files changed, 8 insertions, 0 deletions
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 <tt>count == 1</tt> the singular form will be returned. For any other value of +count+ the plural form will be returned: + +<ruby> +"dude".pluralize(0) # => "dudes" +"dude".pluralize(1) # => "dude" +"dude".pluralize(2) # => "dudes" +</ruby> + Active Record uses this method to compute the default table name that corresponds to a model: <ruby> |