From the Softies on Rails comes a quick summary of idiomatic Ruby naming conventions. To a seasoned Rubyist, these are common knowledge, but I’ve seen many a beginner carrying their baggage from other languages over to Ruby.
In the book, I wrote the following sidebar that covers the basics (from page 330):
Ruby Style
Style is important when programming. Ruby programmers tend to be picky about style, and generally adhere to a few specific guidelines:
- Indentation size is two spaces
- Spaces are preferred to tabs
- Variables should be lowercase and underscored:
some_variable, notsomeVariableorsomevariable - Method definitions should include parentheses and no unnecessary spaces:
MyClass.my_method(my_arg), notmy_method( my_arg )ormy_method my_arg
Whatever your personal style, the most important thing is that you remain consistent. There’s nothing worse than looking at code that switches between tabs and spaces, or mixed and lowercase variable names.

