Skip to content

Instantly share code, notes, and snippets.

@dustinbrownman
Last active November 3, 2023 09:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dustinbrownman/02fd33e8b21842019d4b to your computer and use it in GitHub Desktop.
Save dustinbrownman/02fd33e8b21842019d4b to your computer and use it in GitHub Desktop.
ActiveRecord naming conventions

Active Record naming conventions

Class name    Table name      In belongs_to             In has_many               In has_and_belongs_to_many  
-----------------------------------------------------------------------------------------------------------------------
Task          tasks           belongs_to(:task)         has_many(:tasks)          has_and_belongs_to_many(:tasks)
Person        people          belogns_to(:person)       has_many(:people)         has_and_belongs_to_many(:people)
CreditCard    credit_cards    belongs_to(:credit_card)  has_many(:credit_cards)   has_and_belongs_to_many(:credit_cards)

singular      plural          singular snake case       plural snake case         plural snake case
upper camel   snake case
case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment