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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060119/d5660663/attachment.html
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. Vivek Krishna wrote:> 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 > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 18/01/2006 > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060119/77b26e26/attachment.html
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 1/19/06, Vivek Krishna <krishna.vivek@gmail.com> wrote:> > 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 > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060119/acaf4bd4/attachment.html
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. -- Posted via http://www.ruby-forum.com/.
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 On Jan 19, 2006, at 1:17 PM, Vivek Krishna wrote:> 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 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails