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.
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
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.
E35a1765644521c87665ea20ae35e796?d=identicon&s=25 Kevin O. (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.
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
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.