Forum: Ruby on Rails Pluralis versus Singularis

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.
Af95bdaf87958c40150b813e94381bfd?d=identicon&s=25 Christer Nilsson (christer)
on 2005-11-29 09:07
What would happen if Singularis was used everywhere instead of Pluralis?
(table name User instead of Users, etc)

Are the advantages really outweighing the disadvantages?

There must exist other ways of handling naming conflicts. Like user and
User or tblUser.

Christer
84962fcce3fbde5aef15001d60e242ae?d=identicon&s=25 grzm (Guest)
on 2005-11-29 09:24
(Received via mailing list)
On Nov 29, 2005, at 17:07 , Christer Nilsson wrote:

> What would happen if Singularis was used everywhere instead of
> Pluralis?
> (table name User instead of Users, etc)
>
> Are the advantages really outweighing the disadvantages?

I'm curious: what are the disadvantages of naming tables with
plurals? I was doing this long before using Rails. A table (or
relation) is a set of predicates: it's a collection. To me, it's
natural to tables with a plural.

For legacy databases, of course you have to work with what you're
given. For new projects using Rails, it just means one less thing you
need to configure if you name your tables with plurals: otherwise you
can use set_table_name to name it whatever you'd like.

Michael Glaesemann
grzm myrealbox com
Af95bdaf87958c40150b813e94381bfd?d=identicon&s=25 Christer Nilsson (christer)
on 2005-11-29 09:29
The problem is that pluralize is not complete. The other day one guy
missed five out five plurals. Reason: Pluralize didn't handle them
correctly.

What are the disadvantages of using the singular form everywhere ?

Christer
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2005-11-29 09:52
(Received via mailing list)
On 29.11.2005, at 10.29, Christer Nilsson wrote:

> The problem is that pluralize is not complete. The other day one guy
> missed five out five plurals. Reason: Pluralize didn't handle them
> correctly.
>
> What are the disadvantages of using the singular form everywhere ?

Disadvantages in *you* using them, or disadvantages in *Rails*
ditching the whole pluralisation scheme?

If the former, you have to specify the table name by hand for every
class, so a little more work and less DRYness.

If the latter, well, it's the convention (not only in Rails but in
rdbms literature, too) and it makes a lot of things more "human". An
athlete has_many :fans, not many :fan. And like Michael mentioned,
tables (as opposed to classes) are collections of objects.

Remember, Rails is opinionated software, and the domain-specific
language is definitely one of the things that sets it apart. Also,
the pluralisation scheme is not carved in stone, you're free to
submit patches so that the things that didn't work for you would be
fixed.

Personally, I haven't had a single problem with pluralisation during
my 15 months on Rails. It is true, though, that I've been fortunate
enough to avoid working with legacy databases altogether.

//jarkko
Af95bdaf87958c40150b813e94381bfd?d=identicon&s=25 Christer Nilsson (christer)
on 2005-11-29 10:12
Here are the two examples, that made pluralize fail:

Syllabus has the unusual plural form Syllabi.
Curriculum has the unusual plural form Curricula.

The plural form makes the code more readable, I agree. Writing
users.name in sql is not nice, but rails hides this and uses user.name
instead. And it is easy to add the correct table name by hand if
necessary. And it is possible to augment pluralize as well, and make an
open source patch contribution.

I was just opposing how people defends the pluralization: It's a
convention and therefore not necessary to discuss. But your argument
convinced me.

Maybe the matching between singular forms and plural forms can be
smarter. Example: we have ten models with singular names and ten tables
with plural names. By edit distance comparisons it is possible to find
the most likely mappings. (The edit distance between Syllabus and
Syllabi is two, one replace character and one delete character)

Christer
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 thibaut.barrere (Guest)
on 2005-11-29 10:41
(Received via mailing list)
Hi gentlemen

What is the current process for adding new plurals to the list of
supported
plurals ?

Should we have this list exposed as some kind of moderated wiki online,
to
allow more people (including non technical people willing to help) to
add
new plurals ?

just random thoughts (maybe all this is already in place ?)

Thibaut
Af95bdaf87958c40150b813e94381bfd?d=identicon&s=25 Christer Nilsson (christer)
on 2005-11-29 11:55
In active_support/inflections.rb the rules and exceptions are listed.
Maybe a wiki would be better for linguists uncomfortable with regular
expressions!
A simple database would make the process even easier.
It would also be a help to have a web page for testing in both
directions. Maybe there is one, I didn't find any.
Maybe this is not a problem big enough to spend time on.

Using "would" too many times indicates spending time fixing the code
would be wiser.

Inflector.inflections do |inflect|
  inflect.plural /$/, 's'
  inflect.plural /s$/i, 's'
  inflect.plural /(ax|test)is$/i, '\1es'
  inflect.plural /(octop|vir)us$/i, '\1i'
  inflect.plural /(alias|status)$/i, '\1es'
  inflect.plural /(bu)s$/i, '\1ses'
  inflect.plural /(buffal|tomat)o$/i, '\1oes'
  inflect.plural /([ti])um$/i, '\1a'
  inflect.plural /sis$/i, 'ses'
  inflect.plural /(?:([^f])fe|([lr])f)$/i, '\1\2ves'
  inflect.plural /(hive)$/i, '\1s'
  inflect.plural /([^aeiouy]|qu)y$/i, '\1ies'
  inflect.plural /([^aeiouy]|qu)ies$/i, '\1y'
  inflect.plural /(x|ch|ss|sh)$/i, '\1es'
  inflect.plural /(matr|vert|ind)ix|ex$/i, '\1ices'
  inflect.plural /([m|l])ouse$/i, '\1ice'
  inflect.plural /^(ox)$/i, '\1en'
  inflect.plural /(quiz)$/i, '\1zes'

  inflect.singular /s$/i, ''
  inflect.singular /(n)ews$/i, '\1ews'
  inflect.singular /([ti])a$/i, '\1um'
  inflect.singular
/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i,
'\1\2sis'
  inflect.singular /(^analy)ses$/i, '\1sis'
  inflect.singular /([^f])ves$/i, '\1fe'
  inflect.singular /(hive)s$/i, '\1'
  inflect.singular /(tive)s$/i, '\1'
  inflect.singular /([lr])ves$/i, '\1f'
  inflect.singular /([^aeiouy]|qu)ies$/i, '\1y'
  inflect.singular /(s)eries$/i, '\1eries'
  inflect.singular /(m)ovies$/i, '\1ovie'
  inflect.singular /(x|ch|ss|sh)es$/i, '\1'
  inflect.singular /([m|l])ice$/i, '\1ouse'
  inflect.singular /(bus)es$/i, '\1'
  inflect.singular /(o)es$/i, '\1'
  inflect.singular /(shoe)s$/i, '\1'
  inflect.singular /(cris|ax|test)es$/i, '\1is'
  inflect.singular /([octop|vir])i$/i, '\1us'
  inflect.singular /(alias|status)es$/i, '\1'
  inflect.singular /^(ox)en/i, '\1'
  inflect.singular /(vert|ind)ices$/i, '\1ex'
  inflect.singular /(matr)ices$/i, '\1ix'
  inflect.singular /(quiz)zes$/i, '\1'

  inflect.irregular 'person', 'people'
  inflect.irregular 'man', 'men'
  inflect.irregular 'child', 'children'
  inflect.irregular 'sex', 'sexes'
  inflect.irregular 'move', 'moves'

  inflect.uncountable %w( equipment information rice money species
series fish sheep )
end
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 ezra (Guest)
on 2005-11-29 18:06
(Received via mailing list)
On Nov 29, 2005, at 2:55 AM, Christer Nilsson wrote:

> In active_support/inflections.rb the rules and exceptions are listed.
> Maybe a wiki would be better for linguists uncomfortable with regular
> expressions!
> A simple database would make the process even easier.
> It would also be a help to have a web page for testing in both
> directions. Maybe there is one, I didn't find any.
> Maybe this is not a problem big enough to spend time on.
>
> Using "would" too many times indicates spending time fixing the code
> would be wiser.


Also if you are running one of the new release candidates ( you are
aren't you?), You can add your own pluralization rules to the bottom
of your environment.rb file. There is a section there that is
commented out that shows how to do so.

Cheers-

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
D36eff3004b39abc4b93fe8a410d8bd3?d=identicon&s=25 rm_rails (Guest)
on 2005-11-30 08:19
(Received via mailing list)
Christer Nilsson wrote:
>   inflect.plural /(octop|vir)us$/i, '\1i'

That's a bug, isn't it?

Viri wouldn't be the right plural for virus in
either english (from the Oxford English Dictionary):
    "b Pl. viruses. An infectious organism that..."
or in latin where the word "viri" is a completely
different word meaning "men".  [1]

And octopuses is a more proper plural since the
word has greek rather than latin origins. [2]

[1] http://linuxmafia.com/~rick/faq/plural-of-virus.html
[2] http://en.wikipedia.org/wiki/Octopus#Plural
This topic is locked and can not be replied to.