Tuesday, 19 April 2011

RoR : naming Conventions

controllers
name should be Plural eg.  users, items, teachers
multiwords name should be in  CamelCase,
eg.   UserItems,  UserSessions etc


model
name should be singular and database table name should be plural.
eg. table name : users  ; model name => user
table name :people ; model name => person


Got Lost? How to generate plural form for  table name?
ruby-1.9.2-p0 > "person".tableize
 => "people" 

learn more on text transformation a.k. Text Inflectors 


Table Relationships:
HINT: read it aloud

belongs_to :singularName
has_many :pluralNames
has_on :singularName





A very wonderful  post on RoR naming conventions is posted on  iT signals

1 comment: