On Sunday, December 21, 2014 12:12:56 PM UTC, Varun Wachaspati wrote:
> Hello Everyone
> 
> I am beginner to ruby on rails but lately while working on a Rails Project I 
> stumbled on this anomaly. 
> 
> I encountered this problem while naming my Rails Model Plural (Alumni),my bad 
> forgot the convention and was amazed to find Table name in the database 
> (supposed to be plural of Model name according to the convention) to be 
> Alumnis.
> 


Pluralisation is handled via a set of rules. They aren't perfect but last time 
I checked bugs are not accepted against these rules because it would be too 
easy to break apps that depending on the previous pluralisation (and equally 
it's difficult to be sure that you're not introducing new pluralization errors)

You can add your own rules though - see 
http://api.rubyonrails.org/classes/ActiveSupport/Inflector/Inflections.html

Fred


> Please have a look at this-
> 
> 
> irb(main):001:0> "woman".pluralize
> => "women"
> 
> 
> #Have a look at this one
> irb(main):002:0> "alumnus".pluralize
> => "alumnus"
> 
> 
> #Have a look at this one
> irb(main):003:0> "alumni".pluralize
> => "alumnis"
> 
> 
> irb(main):004:0> "cow".pluralize
> => "kine"
> irb(main):005:0> "man".pluralize
> => "men"
> irb(main):006:0> "cat".pluralize
> => "cats"
> irb(main):007:0> "dolphin".pluralize
> => "dolphins"
> irb(main):008:0> "dog".pluralize
> => "dogs"
> irb(main):009:0> "Tigress".pluralize
> => "Tigresses"
> 
> As you can see that for every other word except Alumnus(whose plural is 
> Alumni) and Alumni(which is itself a plural form) pluralize method returns 
> the exact plural word. Is this a bug in the method implementation?
> 
> Can someone please also explain how the above Rails convention is implemented 
> i.e. Pluralization of Model Name as Table Name in Database
> 
> 
> Thanks in Advance
> Regards

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/96ed1787-603c-4777-9c3f-2e66c8173915%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to