Forum: Ruby on Rails rails naming convention for model: community

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
036be8d5d83a98e546b98d64e3fd6c20?d=identicon&s=25 Sam Donaldson (Guest)
on 2006-05-22 02:07
(Received via mailing list)
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.
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 Peter Michaux (Guest)
on 2006-05-22 02:26
(Received via mailing list)
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.
90842970ceaf7ed19136ce7b6f8e1455?d=identicon&s=25 Michael Daines (Guest)
on 2006-05-22 03:26
(Received via mailing list)
> 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/Infle...

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
D5145c421cd25af6fa577c15219add90?d=identicon&s=25 unknown (Guest)
on 2006-05-22 15:35
(Received via mailing list)
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-...).

You can add others to individual projects by changing environments.rb.
Just look at the commented out bit for an example.

-Nathan
This topic is locked and can not be replied to.