Nameing Conventions: You say Tomato, I say tomatoes...

I am a relative newbie to RoR. How is RoR able to know to look for a
table named "people" from a model class "Person"? Is there a look up
table of some kind or is this defined in a class?

How does RoR handle a model name of "Content"? Would it expect a table
name of "contents" or "content"?

There's a set of inflection rules, but they don't catch everything.
The stock environment.rb file shows you examples to tweak it. Rails
handles all the common cases though.

If you want to try it out, use script/console


The pluralize function is in the Inflector module:

The pluralization rules are in inflections.rb. Here are the rules
used in pluralization from that file:

   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')


I heard some complaints that this works only for the English language,
Is there a way to hack this file to handle other languages, say German


Aaron Baldwin wrote:

Yes, you just have to change it and add your own rules. For example:

inflect.plural(/[aeiou]$/i, '\1en')

The question is: ist es pizzas oder pizzen?


Oops, that should be:

inflect.plural(/([aeiou])$/i, '\1en')