Ruby on Rails Sunday, December 21, 2014

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.
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3701abe6-f87e-4550-9bb2-ff7a6b06ede5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment