Quantcast
Viewing latest article 6
Browse Latest Browse All 10

Model name in RubyOnRails should ALWAYS be singular!!!

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


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 6
Browse Latest Browse All 10

Trending Articles