Skip to content

Instantly share code, notes, and snippets.

@aquaflamingo
Last active May 29, 2021 18:32
Show Gist options
  • Save aquaflamingo/c08d82c2af9a95a2bcb97c5a2394d27d to your computer and use it in GitHub Desktop.
Save aquaflamingo/c08d82c2af9a95a2bcb97c5a2394d27d to your computer and use it in GitHub Desktop.
Rails controller, model, view conventions and naming plural v. single

Rails Conventions Cheatsheet

Taken from https://alexander-clark.com/blog/rails-conventions-singular-or-plural

Concept Plural or Singular Command Example
Controller Plural rails g controller Users index show
Helper Plural rails g helper Users
Mailer Singular rails g mailer UserMailer
Migration Plural rails g migration AddEmailToUsers email:string
Model Singular rails g model User name:string
Observer Singular rails g observer User
Resource Plural* resources :users, :only => [:index, :show]
Scaffold Singular rails g scaffold User name:string
Table Plural SELECT * FROM users;
View N/A app/views/users/index.html.erb – comprised of controller (plural) and action (singular)
@defoebrand
Copy link

Replace the link with this: https://alexander-clark.com/blog/rails-conventions-singular-or-plural

The trailing forward slash on your current link is causing a 404 response

@aquaflamingo
Copy link
Author

Thanks!

@defoebrand
Copy link

Thank you for the resource!

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