Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's rails convention 'username' or 'user_name'?

SHould it be 'username' or 'user_name' when creating a property for a model?

'userstatus or 'user_status'

Are all datetimes ending with '_at' ?

what other ones are there?

like image 693
Blankman Avatar asked Oct 18 '10 01:10

Blankman


1 Answers

variable naming in Ruby tends to follow the convention of all lowercase with underscores separating words (so user_name in your example). There is no special convention for datetimes, Rails just happens to put a couple of attributes on models by default which end with "_at". Other general conventions:

  • method names follow the same convention as variables.
  • constants are generally all upper-case with underscores between words (i.e. MAX_LENGTH).
  • class/module names are generally camel-cased (i.e. HourlyEmployee).
like image 143
Pete Avatar answered Oct 13 '22 00:10

Pete