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 -- Posted via http://www.ruby-forum.com/.
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
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 -- Posted via http://www.ruby-forum.com/.
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 -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 -- Posted via http://www.ruby-forum.com/.
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 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 -- Posted via http://www.ruby-forum.com/.
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-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
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