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
on 2006-01-19 19:55
on 2006-01-19 20:10
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.
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.
on 2006-01-19 20:43
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
on 2006-01-20 03:16
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