The Hitchhiker’s Guide to Ruby On Rails Galaxy

Records of my voyage through RoR Galaxy

Posts Tagged ‘conventions’

Model name in RubyOnRails should ALWAYS be singular!!!

Posted by arjunghosh on December 23, 2008

Model names in RubyOnRails should be Singular. This will create Table name as corresponding Plural names.

You have got to remember that about model naming conventions in rails. . 

I know this is a very basic concept in RubyOnRails but sometimes these simple basic concepts are the ones which slip through the cracks.

Example:

> ruby script/generate model Post

This will create a Model by the name “Post” i.e. singular in english language and a migration to create a table by the name “Posts” which is plural form of “Post”.

I have even put this into a pastie for easier remembarance http://pastie.org/345491

Advertisements

Posted in Uncategorized | Tagged: , , , , , | 7 Comments »