Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Naming conventions for attributes

Im creating a model with the line

rails g scaffold contact firstname:string lastname:string email:string

But should the attributes be like

first_name:string 

instead?

like image 773
Jepzen Avatar asked Jan 19 '12 09:01

Jepzen


1 Answers

Conventions aren't set in stone, but it's good to follow them.

And yes, widely spread convention for attribute names is snake case.

Snake case:

punctuation is removed and spaces are replaced by single underscores. Normally the letters share the same case (either UPPER_CASE_EMBEDDED_UNDERSCORE or lower_case_embedded_underscore) but the case can be mixed.

like image 129
Sergio Tulentsev Avatar answered Sep 26 '22 00:09

Sergio Tulentsev