Skip to content

Instantly share code, notes, and snippets.

@execat
Forked from alexpchin/Ruby_Rails_Naming_Conventions.md
Last active September 25, 2018 20:42
Show Gist options
  • Select an option

  • Save execat/13bf405a4330ffe7c38ff7a61c9f441f to your computer and use it in GitHub Desktop.

Select an option

Save execat/13bf405a4330ffe7c38ff7a61c9f441f to your computer and use it in GitHub Desktop.
Ruby & Rails Naming Conventions

The Ruby Naming Conventions

As Jon would say, ProTip:

Ruby uses the first character of the name to help it determine it’s intended use.

Local Variables
These should be a lowercase letter followed by other characters, naming convention states that it is better to use underscores rather than camelBack for multiple word names eg. mileage, variable_xyz

Instance Variables
Instance variables are defined using the single "at" sign (@) followed by a name. It is suggested that a lowercase letter should be used after the @ eg. @colour

Instance Methods
Method names should start with a lowercase letter, and may be followed by digits, underscores, and letters eg. paint, close_the_door

Class Variables
Class variable names start with a double "at" sign (@@) and may be followed by digits, underscores, and letters eg. @@colour

Constant
Constant names start with an uppercase letter followed by other characters. Constant objects are by convention named using all uppercase letters and underscores between words, eg. THIS_IS_A_CONSTANT

Class and Module
Class and module names starts with an uppercase letter, by convention they are named using MixedCase, eg. module Encryption, class MixedCase

Global Variables
Starts with a dollar ($) sign followed by other characters eg. $global

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment