Reputation: 1783
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)?
Upvotes: 5
Views: 3745
Reputation: 19496
metadata_types
for the table name is fine. From there, you can do
> "metadata_types".classify
=> "MetadataType"
so MetadataType would be the class name expected by rails.
This also works in reverse:
> "MetadataType".tableize
=> "metadata_types"
Upvotes: 9
Reputation: 23678
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
Upvotes: 3