Forum: Ruby on Rails Using RoR pluralization rules

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6828ffc79486cd2442714bf32286a910?d=identicon&s=25 Vivek Krishna (Guest)
on 2006-01-19 19:55
(Received via mailing list)
Hello,
  RoR seems to be aware of plurals like category=>categories etc..I Want
to
be able to use this in my application to relate some keywords.Is it
possible
?or does RoR itself use some ruby library?
Thanks
Vivek
9a40def42f37ff6e3120d625656a0300?d=identicon&s=25 Marc Croom (Guest)
on 2006-01-19 20:10
(Received via mailing list)
RoR uses a mixin module for the String class - you can simply call
functions such as pluralize, singularize etc on any string from within a
RoR application.

The module you want to look at is
ActiveSupport::CoreExtensions::String::Inflections.
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-01-19 20:32
Marc Croom wrote:
> RoR uses a mixin module for the String class - you can simply call
> functions such as pluralize, singularize etc on any string from within a
> RoR application.
>
> The module you want to look at is
> ActiveSupport::CoreExtensions::String::Inflections.

With the caveat that it isn't always right.
9b7647d55df4584d7031130915556040?d=identicon&s=25 Will Briggs (Guest)
on 2006-01-19 20:43
(Received via mailing list)
There is a "pluralize" helper you can use to do this.  Check out the
Rails
API: api.rubyonrails.org and look for the "pluralize" method in
ActionView::Helpers::TextHelper.

-Will
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-01-20 03:16
(Received via mailing list)
Look for this in config/environment.rb

# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
# end

-- -- Tom Mornini
This topic is locked and can not be replied to.