← Back to Upcase

Summary file naming: hyphens, underscores, caps


(Justin Gordon) #1

Has anybody ever seen a great concise summary of best practices for file naming for a Rails project.

  1. Ruby classes: Underscores, all lower case
  2. Coffeescript/Javascript: hyphens (why? https://github.com/thoughtbot/guides/tree/master/style )
  3. Sass: ? Maybe hyphens?
  4. Haml, ERB: Underscores
  5. Yaml files?
  6. Directories (underscores always?)
  7. What else?

The only thing consistent seems to be:

  1. No caps (except README.md ? )
  2. No spaces

(Greg Lazarev) #2

Underscores in file/directory names is a convention that is adopted in the Ruby community.

In JavaScript/CoffeeScript community underscores are predominant in filenames.

AFAIK, Sass has adopted the underscore convention as well.

To summarize, in a Ruby/Rails project use underscores everywhere (JS/CS could be either underscored or hyphenated).


(Justin Gordon) #3

Thanks @greg. I noticed this line in the Thoughtbot style guide. That was what piqued my curiosity.

Use hyphen-separated filenames, such as coffee-script.coffee.