Search code examples
ruby-on-railsnaming-conventionsmodels

Rails multi word Model naming conventions


I have a lookup table called metadata_types in my database, which lists all the various types of metadata my app uses.

Metadata is the plural of Metadatum; should I have called the table metadatum_types? In other words should the plurality be on both words in this case, or just the second? Should the corresponding model then also be metadatum_type.rb (Class MetadatumType)?


Solution

  • metadatum_types is fine. Rails only applies pluralization at the end of the model name.

    The method is rather simple and can be found here: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-pluralize (code)

    The inflections Rails applies to the name can be found here: Inflector.rb