What are naming conventions in ROR?

Naming conventions in Ruby on Rails can be very confusing for those who start out as new web developers due to the many technicalities, so below are some tables you can reference for assistance:

Database table

We will need a database table to base our examples on in this shot. Below is a drawing of the database table:

employee_profiles

column names

type

id_number

INT

experience

INT

name

STRING

position

STRING

Below is a cheat sheet that will help resolve any problems regarding naming conventions:

Cheatsheet


Naming

Formatting

Example and Explanation

Class

Singular

Camel Case

ClassName

Class Method

-

Snake Case

::method_name

Instance Method

-

Snake Case

#method_name

Methods

-

Snake Case

Prefix of '?' returns a boolean

method_name

Variables

-

Snake Case

variable_name

Database Table

Plural

Snake Case

employee_profiles

Database Column Names

Singular

Snake Case

name

Model Class Names

Singular

Camel Case

class EmployeeProfile (corresponds to the database name but singular)

Model Attributes and Methods

-

Snake Case

methods_attributes

Relations

Both singular and plural

Snake Case

'has_one' and 'belongs_to' are singular but 'has_many' is plural

Controller Class Names

Singular

Camel Case

They have Controller as a suffix.

EmployeeProfilesController (corresponds to database table name)

Controller Actions

-

Snake Case

standard defined by rails (index, edit, update, show, new..)

Route Names

Plural

Snake Case

resources: employee_profiles

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved