Hello, How does Rails deal with the pluralization of community. I have "community" as my model name. Will Rails automatically look for a table name "communities" or do I have to name the table "communitys"? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060522/e2fb4d92/attachment.html
On 5/21/06, Sam Donaldson <samonderous@gmail.com> wrote:> Hello, > > How does Rails deal with the pluralization of community. I have "community" > as my model name. Will Rails automatically look for a table name > "communities" or do I have to name the table "communitys"?Rails will look for a table named communities. Rails knows about most correct English pluralizations. I believe this is a Ruby library.
> How does Rails deal with the pluralization of community. I have > "community" > as my model name. Will Rails automatically look for a table name > "communities" or do I have to name the table "communitys"?"community" will become "communities" when pluralized. You may want to have a look at the documentation for Rails'' inflector: http://api.rubyonrails.com/classes/Inflector/Inflections.html Also, if you''re unsure about how a word will be pluralized/ singularized, try Geoffrey Grosenbach''s Pluralizer: http://nubyonrails.com/tools/pluralize -- Michael Daines
njmacinnes@gmail.com
2006-May-22 13:32 UTC
[Rails] rails naming convention for model: community
The pluralisations are done with a load of regular expressions in the inflections.rb file (have a gander: http://dev.rubyonrails.org/svn/rails/tags/rel_1-1-2/activesupport/lib/active_support/inflections.rb). You can add others to individual projects by changing environments.rb. Just look at the commented out bit for an example. -Nathan On 22/05/06, Michael Daines <michael.daines@gmail.com> wrote:> > How does Rails deal with the pluralization of community. I have > > "community" > > as my model name. Will Rails automatically look for a table name > > "communities" or do I have to name the table "communitys"? > > "community" will become "communities" when pluralized. You may want > to have a look at the documentation for Rails'' inflector: > > http://api.rubyonrails.com/classes/Inflector/Inflections.html > > Also, if you''re unsure about how a word will be pluralized/ > singularized, try Geoffrey Grosenbach''s Pluralizer: > > http://nubyonrails.com/tools/pluralize > > > -- Michael Daines > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >